How to force child categories to follow the same layout as parent categories for custom single.php file
Description
In this example events and life groups are parent categories with many children. To force all children to follow the same single.php layout as the parent just change the names of the parent category names and the single.php file name. This code was used on mtsinaicogic.org life groups and events page single.php
PHP Source Code
<?php
$post = $wp_query->post;
$category = get_the_category();
$parent = get_category($category[0]->category_parent);
if ( $parent->slug == 'events' ) {
include(TEMPLATEPATH . '/single-events.php'); }
elseif ( in_category('blog') ) {
include(TEMPLATEPATH . '/single-blog.php'); }
elseif ( $parent->slug == 'life-groups' ) {
include(TEMPLATEPATH . '/single-group.php'); }
else {
include(TEMPLATEPATH . '/single-blog.php');
}
?>