Hi,
Trying to narrow down which categories are shown by parent/child categories in a query loop.
How do I define which one in the loop? Do I just write the name of the category or what do I need to do?
Hi,
Trying to narrow down which categories are shown by parent/child categories in a query loop.
How do I define which one in the loop? Do I just write the name of the category or what do I need to do?
Hi Erik,
Welcome to the forum!
You can use the term ID instead of the name.
Best regards,
timmse
Sorry that I need to bring this up again - did anyone try this? All I would like to do is loop through the subcategories of the current product category to list all the subcategories. I can not imagine that the loop builder is not capable of doing this.
Hey Alexa,
sorry, I bookmarked the thread - but havenāt gotten around to looking into it yet. Iāll get back to you as soon as I can give you a satisfactory answer
Hi Alexa,
Just tested this in 1.5 Beta and it works fine here.
Make sure you are setting this up in a Template that applies to all terms of Product categories.
Hi @Alexa.
Did You managed to get this to work? IĀ“m facing the same issue⦠Using {term_id} in the āParentā field has no effect. Using a fixed value works well.
Hi Sridhar.
Could You explain this a little further?
IĀ“m at the same point as Alexa is / was. If I set the parent id as a fixed value (122) it looks good - but using ā{term_id}ā results in displaying the all categories starting from the alphabetic first.
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
I dont understand step 2 ?
How can i echo that function on that query loop inside builder?
exact same dilema as its the default woo behavior. Did you ever got a solution?
I will try the child of custom function posted in this thread.
What is kinda working for me is this.
Order by Parent and then it first shows all the parents and then all subcategories. So what I did is counted how many parent categories I have (7) and then restricted to display only first 7 categories which are parent categories.
How is there not a simple answer to this? Itās driving me crazy. Iāve read half the forum in search of a solution for this. Why does this have to be so complicated? I canāt get my answer anywhere.