0

I created a custom post type ('explore') that we use in the site. The pages for this section live at http://example.com/explore/page-name

These pages work just fine, but if a user were to back out of that url and go to http://example.com/explore they are getting the generic index.php page that is NOT what we want people to see here.

Considering this url does NOT point to any content, how can I specify which template to use? I can echo out the get_post_type() and it shows 'explore' as the post type, but I'm seeing that from the index.php template.

I tried adding a page-explore.php but that didn't work. There doesn't seem to be a index-[custom-type].php

Thanks.

1
  • if /explore is showing a post archive of that post type then can you not use the standard post archive template from the template hierarchy diagram as outlined in the official handbook docs?
    – Tom J Nowell
    Jan 28 at 18:14

1 Answer 1

5

You're looking for the "custom post type archive template". That's archive-{post_type}.php, or in your case archive-explore.php:

https://developer.wordpress.org/themes/template-files-section/custom-post-type-template-files/

1
  • Works, perfectly. Thanks!
    – Scott
    Jan 28 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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