Parent Cat ID for single.php

<?php

foreach((get_the_category()) as $childcat) {

$parentcat = $childcat->category_parent;

$the_cat_name = get_cat_name($parentcat);

$the_cat_ID = get_cat_ID($the_cat_name);

}
if($the_cat_ID == 4){
echo "parent cat $the_cat_ID <br />";
}
?>

0 Comments

You must be logged in to post a comment.