Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created a page on which I would like to run queries exlusively for one custom post type in the same way I'm using Category.php, Author.php and index.php to run queries for regular posts. I can't seem to get anything to appear when I edit the page that is associated with the template I've created for this page, so I've edited the actual page template itself. This may or may not be related to the fact that I can't get this page to behave like index.php does, i.e. providing a running list of posts until someone does a more refined search such as by Category.

I'm stumped - how can I get a page template to work just like index.php does, but for the custom post type only?

share|improve this question
    
Please go and accept Answers as solution with some of your Qs. You got 0% accept rate. –  kaiser Jun 3 '11 at 17:02
add comment

1 Answer

up vote 1 down vote accepted

You want to use the template file archive-{posttype}.php to output an archive index of your Custom Post Type, and the template file single-{posttype}.php to output a single Custom Post.

Refer to the Codex entry for Template Hierarchy.

share|improve this answer
    
Thanks, Chip. But I've got an unresolved issue with the system not reading my archive-{posttype}.php. It does read my single-{posttype}.php, however. It is registered appropriately, etc. I have to develop a workaround, so do you know if there's a way to have a page -running off of its own template (and I edited the template directly) for a custom post type, to act as index.php does (as the default template) for regular posts? –  mktggirl Jun 6 '11 at 14:30
    
What version of WordPress are you using? IIRC, archive-{posttype}.php only works in WordPress 3.1+. –  Chip Bennett Jun 6 '11 at 15:19
    
I'm using 3.1.3 –  mktggirl Jun 6 '11 at 16:59
    
What do you mean when you say that the system is "not reading" your "archive-{posttype}.php template file? Can you update your question to describe what's happening/not happening as you expect? What is your custom post type named (perhaps post the entire registration code)? What is your archive-{posttype}.php template file named? Also: if you put <?php post_type_archive_title(); ?> in your archive template file, does the Custom Post Type Title output? –  Chip Bennett Jun 6 '11 at 17:15
1  
"Would the latter serve as a destination URL where all queries of the custom post type 'Businesses Sold' could happen?" - YES! That is the purpose of the archive-{posttype}.php template file: to serve as the template file for rendering the archive index of Posts of the Custom Post Type. If you have a static Page of the same name, I honestly don't know how WordPress would handle that. –  Chip Bennett Jun 6 '11 at 19:51
show 14 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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