WordPress tutorials: First category ID of post

Wpsnipp – Adding this to your functions.php of your wordpress theme will allow you to get the first category ID of the current post when calling getParentCatID() from your theme.Show the  category ID:

 

 

function getParentCatID() {
$category = get_the_category();
return $category[0]->cat_ID;
}

Be Sociable, Share!

Leave a comment