Custom Taxonomy – Hiển thị danh sách post type và Gọi post type theo taxonomy slug
https://webexp24h.net/custom-taxonomy-hien-thi-danh-sach-post-type-va-goi-post-type-theo-taxonomy-slug/
1. Khởi tạo Custom Taxonomy
function make_taxonomy_tin_tuc() {
$labels = array(
'name' => 'Categories',
'singular' => 'Category',
'menu_name' => 'Categories'
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy('cat-tin-tuc', 'tin-tuc', $args);
}
add_action( 'init', 'make_taxonomy_tin_tuc', 0 );
2. Viết Shortcode hiển thị custom post type qua custom taxonomy name slug
2.1. Tạo shortcode
2.2. Hiển thị short code trong bài viết và trong file php
PreviousWORDPRESS CUSTOM TAXONOMY TOÀN TẬPNextLấy bài viết, custom post type từ category, post_type, custom taxonomy phần 1 (ok)
Last updated