We design and develop websites, digital experiences, and software solutions for growing businesses.
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 } ?> |