WordPress – Different Post Templates Per Category
Similarly Interesting Articles...
Define different post templates based on the category they belong. This is useful if you want each posts on different category to have different looks. To do this please follow this:
1. Copy single.php to single-default.php. Your default template will be single-default.php
2. On single.php file remove all contents and insert the this code.
<?php
$post = $wp_query->post;if (in_category(’1′)) {
include(TEMPLATEPATH.’/single1.php’);
} elseif (in_category(’2′)) {
include(TEMPLATEPATH.’/single2.php’);
} else {
include(TEMPLATEPATH.’/single_default.php’);
}
?>
3. Copy single-default.php to single1.php (template for category number 1) and modify it based on your preferences. Repeat the process on each category templates.






