I've created a custom post type for this project I'm working on. I've defined the URL slug to be 'vendors'.

So now when I browse to www.mysite.com/vendors, it shows all of my Custom Post Type posts.

I don't want the root slug to be a listing of all my posts.

Is there a way to have a custom template defined for the /vendors/ slug?

  • Hard to answer without more detail. I would suspect bad code in the template or a bad pre_get_posts filter. – s_ha_dum Nov 19 '13 at 16:55
  • 1
    Did you specify a custom archive-vendors.php template? – Sven Nov 19 '13 at 16:57
  • I can post my register_post_type code if it'll help. Basically the post type is working fine. I've populated it with a bunch of posts. But when I browse to just the root. mysite.com/vendors. I get a list of all my posts. Sort of like a custom is_home(). I'm looking to replace the post listing with my own template code - I just don't know the hook to do it. – Pat Nov 19 '13 at 16:58

There are a couple of solutions:

  1. Create archive-vendors.php, that displays whatever output you want (including static content or a secondary query, for example), and omitting the default loop (CPT archive index query).
  2. Set has_archive to false in your register_post_type() call, then create a static page named Vendors, that you can use to display whatever content you want (including via a custom page template).
|improve this answer|||||
  • I created a archive-vendors.php to my theme folder, and set has_archive to true, yet I'm still getting a post listing like is_home(). Any thoughts? – Pat Nov 19 '13 at 18:28
  • Ah, I was playing around with option 1 and 2, and it looks like after I made my changes, I had to reset my permalinks again. I ended up going with option 2, since that will involve the least amount of work required. Thanks! – Pat Nov 19 '13 at 18:31

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.