I have registered taxonomy:

$taxonomySetup = [
    'label' => __('Products catalog'),
    'has_archive' => false,
    'hierarchical' => true,
    'rewrite' => [
        'slug' => __('catalog'),
        'hierarchical' => true,
        'with_front' => true
register_taxonomy('products', ['product'], $taxonomySetup);

add_action('init', 'addTaxonomiesToPages');
function addTaxonomiesToPages() {
    register_taxonomy_for_object_type('products', 'product');

which is linked to CPT:

register_post_type('product', [
    'labels' => [
        // labels definitions
    'public'                => true,
    'has_archive'           => true,
    'menu_icon'             => 'dashicons-archive',
    'show_in_nav_menus'     => true,
    'taxonomies'            => ['products'],
    'publicly_queryable'    => false,
    'rewrite' => [
        'pages' => true,
    'supports' => [
        // supported items

Now I have categories (for this taxonomy) structure with results:

  • http://example.com/catalog - Not Found
  • http://example.com/catalog/subcategory-1 - taxonomy.php
  • http://example.com/catalog/subcategory-1/subcategory-2 - taxonomy.php
  • http://example.com/catalog/subcategory-1/subcategory-2/subcategory-3 - taxonomy.php
  • http://example.com/catalog/subcategory-1/subcategory-2/subcategory-3/subcategory-4 - taxonomy.php

I have created many files for it:

  • taxonomy.php
  • taxonomy-products.php
  • taxonomy-product.php
  • taxonomy-catalog.php

Why it always loading base taxonomy template and for main catalog it rendering 404 error?

btw. How can I control which template should be loaded for subcategory (I'm talking about sub-level, not naming)?


There is no direct template for subcategories/subterms. both will be accessible in taxonomy.php I didn't get what's your requirement to have a separate page for subcategories/subterms. but you can handle this on taxonomy.php

if( subcat ){
 // show sub category view
}elseif(parent) {
 // show parent category view 

or check this answer more related to your request Different template for subcategories

  • Now I want to know, why taxonomy not loading template for it, only base. – Paul Jan 31 '18 at 9:02

WordPress provides archive pages for taxonomy terms, not for taxonomies. As catalog is the taxonomy slug http://example.com/catalog returning a 404 is the expected behaviour.

A work-around for this situation is to create a new page with the slug catalog, and then use the page-catalog.php template with a custom query and loop to suit your needs.

http://example.com/product may provide what you're looking for. This page would use archive-product.php.

As you have rewrite defined in your register_taxonomoy call you will need to flush rewrites for the new rules to take effect.

  • I have tried with archive.php, archive-product.php, archive-products.php and nothing, still 404. (I have set has_archive to true and 're-saved' permalinks) – Paul Jan 31 '18 at 10:15
  • Every time I'm going to Settings > Permalinks and I'm clicking Save. – Paul Jan 31 '18 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.