I I am looking for a function that merely returns true or false. The function would check if the category archive being queried is a child of a particular parent category. The function would look something like this (similar to the is_category()
function):
if(is_child_of_category('3')){ //do something }
if(is_child_of_category('4')){ //do something else }
if(is_child_of_category('5')){ //do something entirely different }
I have looked through the documentation and the forums but have not found any solutions, any ideas if this has been done or how one would go about it?
///////////// addendum ////////////
Here is the working code that I wrote with help from Gavin:
Thanks Gavin
first a function for the functions.php file to get the category id:
function getCurrentCatID(){
global $wp_query;
if(is_category() || is_single()){
$cat_ID = get_query_var('cat');
}
return $cat_ID;
}
Next use cat_is_ancestor_of
$post = $wp_query->post;
$id = getCurrentCatID();
if ( cat_is_ancestor_of(3, $id) { include(TEMPLATEPATH . '/unique.php'); }