Loop by category and meta_key

get_the_category() will retrieve the category of current loop item. In your case, it’s probably the last post of your main archive query. To get the category of currently displayed category in the archive page, you can use get_queried_object_id(): // Check if this is a category archive if ( is_category() ) { // Get the current … Read more

outputting taxonomy hierarchy

OK, so if the empty terms shouldn’t be displayed in there, then it’ll be pretty easy 😉 All you have to do is to use wp_list_categories function: <ul> <?php wp_list_categories( array( ‘taxonomy’ => ‘sfcategory’, ‘title_li’ => false, ‘hide_empty’ => true // or false, as you wish ) ); ?> </ul>