Một ví dụ kinh điển sử dụng Custom Post Type && Custom Taxonomies dùng chung đường dẫn (ok)
Chú ý: Taxonomy và post type không bao giờ được trùng nhau :( xem ảnh:

C:\xampp\htdocs\wordpress1\wp-content\themes\twentytwentyone\functions.php
// ===========
add_action('init', 'my_realisaties_taxonomy', 30);
function my_realisaties_taxonomy() {
$labels = array(
'name' => _x('Realisaties', 'taxonomy general name'),
'singular_name' => _x('Realisatie', 'taxonomy singular name'),
'search_items' => __('Search Realisaties'),
'all_items' => __('All Realisaties'),
'parent_item' => __('Parent Realisatie'),
'parent_item_colon' => __('Parent Realisatie:'),
'edit_item' => __('Edit Realisatie'),
'update_item' => __('Update Realisatie'),
'add_new_item' => __('Add New Realisatie'),
'new_item_name' => __('New Genre Realisatie'),
'menu_name' => __('Realisatie Taxonomy'),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'realisaties'),
'show_in_rest' => true,
'rest_base' => 'realisatiesabc',
);
register_taxonomy('realisatiesabc', array('realisaties'), $args);
flush_rewrite_rules(true);
}



C:\xampp\htdocs\wordpress1\wp-content\themes\twentytwentyone\taxonomy-realisatiesabc.php
C:\xampp\htdocs\wordpress1\wp-content\themes\twentytwentyone\single-realisaties.php


PreviousGet wordpress post by post title (ok)NextThay đổi Custom Post Type && Custom Taxonomies khi thay đổi ngôn ngữ Phần 1 (ok)
Last updated
Was this helpful?