0

For standard posts my theme automatically displays the terms I added for Categories and displays these after the_content(); on the front end, where I click a term and it goes to a page listing all posts that use the term.

So I set up a custom post type with a custom taxonomy assigned to it. But unlike standard posts my theme does not display the category terms for them. So I add a snippet I found (where Genres is the taxonomy name):

the_terms( $post->ID, 'genres', 'Genres: ', ', ', ' ' );

This shows the terms for me to click on the front end for the CPT. When I do the result is a page not found rather than an archive page for terms as for a standard post.

Is it essential to add a taxonomy.php template file to child theme or is the problem the snippet? I thought wordpress uses archive.php automatically or is that only for regular posts associated with default categories?

I tried adding a taxonomy.php to my child theme (based on code from archive.php) but it's got get_template_part with called in files so could be doing something wrong. Before I check with the theme provider on specifics I wanted to establish some basics.

Also I don't have an archive.php in my child theme but there's one in the parent theme folder is this ok.

thanks!

2
  • have you flushed re-write rules? Commented Mar 26, 2019 at 8:59
  • 1
    I did this for the custom post type but forgot or didn't realise it was also required for the new taxonomy. You saved my bacon again. So it uses archive.php then, no need for another template, taxonomy.php. A simple and beautiful thing
    – MatJon
    Commented Mar 26, 2019 at 10:13

1 Answer 1

1

It seems like Qaisar has answered your question with "have you flushed re-write rules?".

However, I would like to clarify that it is NOT essential to add a taxonomy.php unless for some reason you are querying specific posts on the archive.php that doesn't include this taxonomy. The order of Wordpress file execution can be seen below by priority order:

taxonomy-your_taxonomy-term_slug.php

taxonomy-your_taxonomy.php

taxonomy.php

archive.php

index.php

1
  • Thanks Jared. Yes Qaisar was a great help as always. I can't see a tick icon for his response in order to accept his answer so I simply thanked him in my earlier response. I have therefore accepted yours
    – MatJon
    Commented Mar 28, 2019 at 2:52

Your Answer

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

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