Custom Taxonomy Leads to 404 Page – Permalink Structure Flushed

Remove the slashes on your rewrite slug. Should be like so:

 ...
 'rewrite'           =>  array('slug' => 'products', 'with_front' => false)
 ...

Also, you can’t have the same slug for both a taxonomy and a custom post type. They need to be unique, otherwise WP won’t know which one applies to which.

Additionally, if you have the slug of your custom post type as products, you cannot have a page with a slug of products also, otherwise that will cause conflicts.

Finally, for a custom taxonomy listing of these, you want the file to be titled taxonomy-{taxonomy_name}.php, so in your case, it should be titled taxonomy-custtax.php.

For best luck, I would suggest taking this in steps:

First, setup the custom post type. Then, if you set the slug to products (after flushing rewrite rules), visit www.mysite.com/products (again, be sure nothing else in your install has a slug of products). You should see a listing of your products (assuming you have added some product entries).

Then, add your archive-custcpt.php file to your theme, modify it in some unique way, and refresh. You should see that it is now loading your list of products within that new template.

Then, add in your custom taxonomy. If your taxonomy slug is prodcat (for products category), you should be able to visit www.mysite.com/prodcat/[term] (where [term] = a product category you have set up).

Lastly, add your taxonomy-custtax.php file, modify it in some unique way, and refresh. You should see the listing showing up in your new template file.

Leave a Comment