Custom Taxonomy Tags and Category using same slug

I seem to had hit a problem with using the same ‘slug’ => ‘publications’, for register_taxonomy _category and _tag. It seems only the last call register_taxonomy(‘publications_tag’, is able to use the slug. Where as the previous call register_taxonomy(‘publications_category’, renders a 404.

How can I use the same slug for category and tag, which I assume would then use my taxonomy-{post-type_.php template?

// Custom Post Type:

register_post_type( ‘publications’, $args );

$args = array(
‘label’ => __( ‘Publication’, ‘text_domain’ ),
‘description’ => __( ‘Publications’, ‘text_domain’ ),
‘labels’ => $labels,
‘supports’ => array(
‘title’,
‘editor’,
‘thumbnail’,
‘excerpt’,
‘revisions’,
‘author’,
‘post-formats’,
//’comments’,
‘page-attributes’
),
‘taxonomies’ => array(
‘publications_category’,
‘publications_tag’
),
‘hierarchical’ => false,
‘public’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘menu_position’ => 20,
‘menu_icon’ => ‘dashicons-align-left’,
‘show_in_admin_bar’ => true,
‘show_in_nav_menus’ => true,
‘can_export’ => true,
‘has_archive’ => ‘publications’,
‘exclude_from_search’ => false,
‘publicly_queryable’ => true,
‘capability_type’ => ‘post’,
‘show_in_rest’ => true,
‘rewrite’ => array(
// ‘slug’ => ‘publications’,
‘with_front’ => false
),
);

// Categorys:

register_taxonomy(‘publications_category’, ‘publications’, array (
‘labels’ => array (
//
),
‘hierarchical’ => true,
‘show_ui’ => true,
‘show_tagcloud’ => true,
‘rewrite’ => array(
‘slug’ => ‘publications’,
‘with_front’ => false ),
‘public’ => true
)
);

// Tags:

register_taxonomy(‘publications_tag’,’publications’, array(
‘labels’ => array (
//
),
‘hierarchical’ => false,
‘rewrite’ => array(
‘slug’ => ‘publications’,
‘with_front’ => false ),
)
);

Read more here:: Custom Taxonomy Tags and Category using same slug

Leave a Reply

Your email address will not be published. Required fields are marked *