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.
<?php if( is_category() ) { $query_cat = get_query_var('cat'); $cat = get_category( $query_cat ); echo $cat->category_parent; // Display the ID } ?> |