9

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'?

2 Answers 2

18

Try single-events.php.

See Template Hierarchy in Codex for full scheme of templates.

2
  • Works a charm, I'm only getting used to how WordPress works, i honestly didn't know it was this flexible!
    – dotty
    Commented Oct 6, 2010 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
    Commented Oct 6, 2010 at 11:12
1

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.

2
  • 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?
    – a_fan
    Commented Nov 4, 2011 at 9:46
  • It's part of page templates. Read about the template hierarchy here: codex.wordpress.org/Template_Hierarchy
    – jaredwilli
    Commented Nov 15, 2011 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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