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.

can I assign a template file to custom post types?

I have created a custom post type called items, and I would like to assign templates to the items like you can do with pages.

share|improve this question
add comment

3 Answers

You can create template for custom post types by creating files, like for example :

single-mycustomposttype.php

See Template Hierarchy in the codex.

PS : this has already been answered.

share|improve this answer
    
Thanks for that, but what I would like to know is if it is possible to add custom templates to custom post types. So for instance can I create two templates and assign each template to it's respective post? That only allows for specifying one template file to handle that specific post type as far as I understand it. –  Odyss3us Jul 21 '11 at 17:05
    
Is see, if you need different templates for single posts, you may want to create several custom post types, according to each needed template. I guess that depends on how many different templates you need. what are you going to do in the templates that needs to be different on each post ? –  mike23 Jul 22 '11 at 10:03
add comment

Yes you can do it, it is a little complex to write here so my anser will be links.

http://www.wptavern.com/forum/general-wordpress/1837-custom-post-types-different-templates.html

http://www.wpbeginner.com/wp-themes/create-custom-single-post-templates-for-specific-posts-or-sections-in-wordpress/ ( this is for posts but you can modify it for CPT's)

http://www.nathanrice.net/blog/wordpress-single-post-templates/ ( this is for posts but you can modify it for CPT's)

It's a good idea for a plugin actually.

share|improve this answer
add comment

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.