Custom Post Type Templates?

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 🙂

2 Answers
2

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.

Leave a Comment