Im using a archive-cpt.php template page to display all my custom post type posts but now I will be categorizing them in taxonomies. I want to add a dropdown filter navigation that will be populated by the name (and link?) of each taxonomy.

I was wondering if I could use the same template and populate it dinamically for title, description and posts or should I do a taxonomy-cat-cpt.php?

I'd love to just use one page and make it load via ajax or maybe just reload but with the same template. Any thoughts?

1 Answer 1


You can create taxonomy-cat-cpt.php, and inside it just use:

<?php get_template_part( 'archive-cpt' ); ?>

Then they'll both use the same template.

Then inside archive-cpt.php, if you use the_archive_title() archive the_archive_description() it will display the appropriate title and description automatically based on whether you're viewing the taxonomy or post type archive.

Regarding posts, as long as you're using the main query (so just have_posts() and the_post() and no new WP_Query() nonsense), then the appropriate posts should be listed, as long as you're using the correct links.

For anything else that needs to be different, you can check is_tax( 'cat-cpt' ) or is_post_type_archive( 'cpt' ) to conditionally hide or show elements for each one.

  • for some strange reason using the get template part gets me a white screen, but copying everything to a new file works.. Jun 7, 2019 at 19:24
  • Oh, sorry, my mistake. With that function you need to omit the .php. I’ve updated my answer. Jun 8, 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.