Inspiration For Creative Minds
Home » Labs » How to get ID of parent category in WordPress  

Filed under Labs

Some times you need to get ID of the parent category. Here is the code which will display the ID of parent category. this code will work fine with WordPress versions 1.5.1 and above.

	if( is_category() ) {
	  $query_cat = get_query_var('cat');
	  $cat = get_category( $query_cat );
	  echo $cat->category_parent; // Display the ID
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook

Posts you may like: