Is it possible to display a different theme based on whatever category you’re in?
For example:
blog.example.com/category/foo -> style1.
blog.example.com/category/bar -> style2.
A Google search brought up this page, and he recommends doing this in single.php:
$post = $wp_query->post;
if ( in_category(5) ) {
include(TEMPLATEPATH . '/style1.php');
} else {
include(TEMPLATEPATH . '/style2.php');
}
Is this the way to go?
You shouldn’t really be using
includefor this. WordPress has an amazingget_template_partfunction just for these situations. It has a built-in fallback mechanism, and integrates nicely with your theme:Then, just name your files with the category slug:
Remember to also have a default
for-category.phpfile, so that you can fallback to that if you don’t have a custom file for the current category.