How do I select parent or child when using terms query loop?

I have a workaround for this and it works.

First step: Create the function to get the id of the current category:

function getCurrentCatID(){
global $wp_query;
if(is_category() || is_single()){
$cat_ID = get_query_var('cat');
return $cat_ID;

Step 2: put dynamic option in parent loop with: {echo:getCurrentCatID}

This way it allows to make the filter without problems showing the subcategories

1 Like