How to get ID of parent category in WordPress

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

Related posts:

HTML5 page structure

HTML5 offers more powerful structure comparing to older versions of Html. There are many new …

Partner with Us

We are providing an exclusive partnership offer to individuals and companies who are interested in setting up their own web design & development company. For more information about how to partner with us, please contact us