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.

Hay, i have a custom post type "Events", however this is basically a post type, so it inherits the post.php template page.

Is there anyway to use a different template (i.e events.php) if the content type is an 'event'?

share|improve this question
add comment

2 Answers 2

up vote 7 down vote accepted

Try single-events.php.

See Template Hierarchy in Codex for full scheme of templates.

share|improve this answer
    
Works a charm, I'm only getting used to how WordPress works, i honestly didn't know it was this flexible! –  dotty Oct 6 '10 at 11:03
    
Yep, templates are extremely flexible system. Just be aware that some frameworks (like Hybrid) apply their own template hierarchy, defaults are not set in stone. –  Rarst Oct 6 '10 at 11:12
add comment

This is why using the custom template files that you can use like page-{post_type}.php and single-{post_type}.php are extremely handy. And in 3,1, archive-{post_type}.php too.

So yea, you just create a template file for your post types, using the custom templates like that instead of the way where you put the template name in a comment at the top of the file. That way sucks, and I never ever use it, and I create post types like maddness.

share|improve this answer
    
I read about single-{post_type}.php and archive-{post_type}.php in codex. Couldn't find a reference for page-{post_type}.php Are you sure about this? Can you share some reference? –  afnrf Nov 4 '11 at 9:46
    
It's part of page templates. Read about the template hierarchy here: codex.wordpress.org/Template_Hierarchy –  jaredwilli Nov 15 '11 at 4:40
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.