I have pages and product categories on my site:
Pages:
--About
--Contact
Products:
--Category 1
----Subcategory 1
--Category 2
Ideally I want mysite.com/category-1/subcategory-1 to show the product category page and mysite.com/about to show a normal page. I have registered the taxonomy in the following way:
function products_taxonomy() {
register_taxonomy(
'product_categories',
'product',
array(
'hierarchical' => true,
'label' => 'Product Categories',
'query_var' => true,
'rewrite' => array(
'hierarchical' => true,
'slug' => "https://wordpress.stackexchange.com/",
'with_front' => false
)
)
);
}
add_action( 'init', 'products_taxonomy');
Currently, the category URL is working, but the page URL eg mysite.com/about/ is 404ing.
I have installed the Rewrite Analyzer plugin and I can see this is because WordPress is only checking for a product category called “about”, which it can’t find, hence the 404. It is not checking subsequent rewrite rules. Is there a way I can catch this 404 and get WordPress to check the next rewrite rule instead of immediately showing a 404? I’m a bit confused as to why this is not the default behaviour…