I am creating a Wordpress Custom Post Type including a taxonomy, after installing, all permalinks where flushed, however the taxonomy archive page is constantly giving me 404.
The CPT archive page works perfectly fine.
Code to create:
add_action( 'init', 'register_cpt_post_type' );
function register_cpt_post_type() {
register_post_type( 'offers',
array(
'labels' => array(
'name' => 'Offer Posts',
'menu_name' => 'Offers Manager',
'singular_name' => 'Offer post',
'all_items' => 'All Offers Posts'
),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'post-formats', 'revisions' ),
'hierarchical' => false,
'has_archive' => 'offers',
'show_in_rest' => true,
'taxonomies' => array('offers-category')
)
);
register_taxonomy( 'offers-category', array( 'offers' ),
array(
'labels' => array(
'name' => 'Offer Categories',
'menu_name' => 'Offer Categories',
'singular_name' => 'Offers Category',
'all_items' => 'All Categories'
),
'public' => true,
'hierarchical' => true,
'show_ui' => true,
'show_in_rest' => true,
'rewrite'=>array( 'slug'=>'offers' )
)
);
}
If I try access www.xxx.com/offers -> that works perfectly fine and gives me the archive page template
If I try access www.xxx.com/offers/food -> Where food is a category created, page leads to 404.
Can you some please guide me if I am setting up something wrong?