I have the following category structure on my blog:
Category Articles
- Sub Articles
- Sub Articles
- Sub Articles
- Sub Articles
Category Products
- Sub Products
- Sub Products
- Sub Products
- Sub Products
I would like to serve a different single.php for each of the two parent categories (and subsequent child categories). So far I have:
<?php
if (in_category('9')) {
include(TEMPLATEPATH . '/single-articles.php');
} else {
include(TEMPLATEPATH . '/single-products.php');
}
?>
Which would work if I had no child categories beneath articles. I would rather not limit myself to just one article category. Something like this would be great:
<?php
if ((in_category('9')) || or child category of 9) {
include(TEMPLATEPATH . '/single-articles.php');
} else {
include(TEMPLATEPATH . '/single-products.php');
}
?>
I've also tried to use the following code by Kaf:
function is_category_parent($category_id='') {
global $wp_query;
if (!$wp_query->is_category)
return false;
$catobj = $wp_query->get_queried_object();
if( ($category_id == $catobj->cat_ID) || ($category_id == $catobj->category_parent) )
return true;
return false;
}
My guess is that it's not compatible w/2.7.
Any help would be appreciated. This is the last hurdle to cross :)