I have a custom post type, named 'products', it has a custom taxonomy that is called 'collections'.
This is how I have registered the taxonomy.
$productTaxonomyArgs = [
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_admin_column' => true,
'description' => __('Product category', 'byronposttypes'),
'hierarchical' => true,
'rewrite' => [
'slug' => __('collections', 'byronposttypes'),
'with_front' => true,
'hierarchical' => true,
'ep_mask' => EP_CATEGORIES
],
];
register_taxonomy('collections', 'products', $productTaxonomyArgs);
register_taxonomy_for_object_type('collections', 'products');
I have created a taxonomy template by the name taxonomy-collections.php.
<?php
get_header();
$post = null;
echo '<h1>taxonomy-collections.php</h1>'; //Echo this to make sure the template works.
if (have_posts()) {
while (have_posts()) { //rest of the code
When I navigate to /collections/lifestyle
(lifestyle is one of the taxonomy terms), the <title>
is 'Lifestyle Archives - [sitename]', so Wordpress does recognise the url as a taxonomy term archive. The problem is, that it doesn't even echo <h1>taxonomy-collections.php</h1>
to the page. That makes me assume that the taxonomy-collections.php
is not recognised by Wordpress.
Any idea as to what I am doing wrong? Thanks a lot for reading and helping!
I found out that Wordpress is falling back to index.php. But is_tax();
returns true
. Not a single one of the taxonomy-specific templates seem to work (taxonomy.php
, taxonomy-collection.php
and taxonomy-collection-lifestyle.php
), not even archive.php
will work.
taxonomy.php
does not work.archive tax-collections term-lifestyle term-99 logged-in wpb-js-composer js-comp-ver-5.0.1 vc_responsive
. I also tried creating archive.php to see if that would work, but that also had no effect. The header and footer are included when loading the page