WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to set up templates for custom post types?

For example you have a portfolio page with 4 different variations of layout and you want the user to be able to pick which layout they want for this post/page?

Wondered if any of you good folk knew of a way?

Thanks :)

share|improve this question
The user being the site admin, or the guest? if the later then take a look at wordpress.stackexchange.com/questions/8608/… – Bainternet Nov 14 '11 at 12:23

First ofcourse we have single-<posttype>.php but I don't think that's what you want ( yay if it is )

To implement this, you would need a metabox, with a dropdown that saves the value to a custom field, which you would then pull from in single-<posttype>.php and then use in an include statement. single-.php would thus only output headers etc if no option was specified, else it would use get_template_part() or include to load the correct template

How you populate that combobox/dropdown is up to you. You may have 5 preset templates and hardcode the filenames, or you may decide to put in code that checks each files header like Wordpress does with pages.

share|improve this answer
I usually use <?php echo get_post_meta($post->ID, 'meta-box-name',true); ?> to get my meta box info, how would i write an if statement to say if meta bot drop down 1 do this if 2 do this else etc...? – Jezthomp Nov 14 '11 at 13:33
$value = get_post_meta($post->ID, 'meta-box-name',true); if($value == 1){ // do this... } else if($value == 2){ // etc.. – Tom J Nowell Nov 14 '11 at 14:35
Thanks Tom i'll give that a go, since your help i've found this also, do the same thing? wordpress.org/extend/plugins/custom-post-template – Jezthomp Nov 14 '11 at 14:52
Almost, that does it for normal posts, not custom posts, at which point you should really be using custom post formats instead. – Tom J Nowell Nov 14 '11 at 15:05

Why not just setup custom post templates so they can choose anyway?

share|improve this answer

Your Answer


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.