WordPress Howto retrieve top parent category ID from the post
Add the following code in your theme functions.php
function is_parent_category($cats, $_post = null)
{
foreach ((array) $cats as $cat)
{
$descendants = get_term_children((int) $cat, "category");
if ($descendants && in_category($descendants, $_post))
return true;
}
return false;
}
?>
Usage:
if (is_parent_category(1)) // Got true/false if parent category is 1
{
//Do something
}
levin 12:16 pm on December 18, 2009 Permalink |
a better method is declare a distinguish var in jQuery.noConflict
var $myjQ = jQuery.noConflict();