How To Display A Woocommerce Subcategory Archive In Query Loop?

How to set a query loop that outputs only the sub-categories of a specific woocommerce category?

Main Category: Cars
First Level Sub Categories: Hatchback, Sedan, SUV

Second LevelSub Categories — For Hatchback: Sports, Commute, Tuned

How to create a query loop that displays only the sub categories in the first level ?

If you know the category… just use PARENT in the query- e.g. PARENT = Cars
You can select the term from a menu.

If you want all children of the current category (e.g. you’re on an archive page and want to show parent cats of the current cat). Then put {term_id} in the PARENT field in your query.

1 Like

Thanks. Is it possible to display only the first-level sub categories?

At present when i add a Parent {term_id} the query outputs all the sub categories of the parent

Put a 0 (zero) in the parent box on the query.

1 Like

@dushyanth, did you find the answer to this? I’m currently having the same issue

Okay, so I now see what @digismith was trying to say. but 0 only returns the parent, in the example above what @dushyanth wanted was to get the “first level sub”. For this to work you have to know the ID of the parent category, in this case, cars and put it in the parent field in the query builder loop e.g. let’s say the cars category ID is 32 then when you put it in the parent field you’ll get Hatchback, Sport, Commute, Tuned … I found the answer here:
tern query section

I ended up getting the intended result by using ‘Child Of: {archive_title}’ in the Query Loop settings

1 Like

A better way is here:


Can get you the CURRENT term ID - so you don’t need to know the category - thus you can use it for all category pages.

1 Like