I have several custom post types on a site where top-level nav items use archive-{post-type}.php templates of the post types. These have recently had a template problem and they now use the index.php template, instead of their archive template. This is possibly after I added a custom taxonomy to the end of functions.php (below), but only because this is the most recent significant change to functions. They still use the correct archive templates on our production site, but not on the development site, where changes have been made.

I've tried removing the taxonomy action, no change.

I've tried saving permalinks in admin settings, no change.

Also maybe relevant: this also only affects top-level templates - there are several custom post types with rewrites to eg domain.com/media-center/articles - and the articles for these work as expected.

I've not faced this issue before and haven't yet found any solutions that resolve it. Is there anything that I can check that might be causing it - or a way to get to the bottom of the issue?

The recently added taxonomy:

add_action( 'init', 'create_year_taxonomy' );
function create_year_taxonomy() {
  // translations for GUI
  $labels = array(
    'name' => _x( 'Edition Year', 'taxonomy general name' ),
    'singular_name' => _x( 'Year', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Years' ),
    'all_items' => __( 'All Years' ),
    'parent_item' => __( 'Parent Year' ),
    'edit_item' => __( 'Edit Year' ), 
    'update_item' => __( 'Update Year' ),
    'add_new_item' => __( 'Add New Year' ),
    'new_item_name' => __( 'New Year' ),
    'menu_name' => __( 'Years' ),
  // register the taxonomy
  register_taxonomy('year',array('the_street_view'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_in_rest' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'year' ),
  • Sounds like you've tried the most obvious options (permalinks, remove added code) an obvious next step is to copy prod to dev again but I'm guessing you have other changes to retain in dev. If you are using Git for managing your code, a git bisect could help isolate the offending code issue.
    – jdm2112
    Sep 13, 2022 at 19:24
  • 1
    Though you don't mention changes of the sort template_include filters and rewrite rules are both plausible culprits for this behavior. The former can change which template file is loaded for a query and the latter can change a query which is produced for a URL - so either might result in a different template being loaded at the same URL. A new taxonomy registration is unlikely to be the source. You might var_dump() the $wp_query global at the top of the erroneous template in order to examine the query (or use something like Query Monitor) and ensure it is as you would expect for that URL
    – bosco
    Sep 13, 2022 at 19:46
  • @bosco this is really helpful, thanks. It shows that a page displaying correctly has this query: post_type=offices but a page displaying incorrectly shows the query: year=about-us. This appears to be affected by my latest taxonomy (in original question) in some way - but I'm not sure why this is happening or how to resolve. I tried removing the taxonomy from functions (and nuking all functions content as a test) but the issue remained. Any ideas for next steps?
    – Mike
    Sep 14, 2022 at 9:17
  • 1
    @bosco further, issue fixed: removed the taxonomy in functions AND updated permalinks and it's resolved. This was all thanks to using Query Monitor to understand what was being requested - so thank you for that tip and have added it to my essential tools!
    – Mike
    Sep 14, 2022 at 9:27

1 Answer 1


The issue was, in fact, the new taxonomy using "year" clashes with the query.

Wordpress was accepting year=about-us in the query chain for instance, as year was a taxonomy, before the expected page=about-us - preventing it from appearing as a page and using the index.php template as there is no "year" template.

I changed year to a more custom slug edition-year in functions.php and flushed the permalinks, which resolved the issue.

  • 1
    Right on! That totally makes sense - I'm glad you got it sorted :)
    – bosco
    Sep 14, 2022 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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