7

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

14

Try single-events.php.

See Template Hierarchy in Codex for full scheme of templates.

  • 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
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.

  • 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 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

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.