[Solved] How to Query Direct Children of a Term Instead of All Children

I have a WooCommerce product archive and I’m trying to only show the direct subcategories but what is showing up instead is all child categories including those that are nested within others.

Here’s a screenshot of my query loop.

I searched but could not find an answer.

Thanks for any help I can get.

Are you trying to show top-level product categories?

Hey Sridhar,

Thanks for asking a clarifying question.

I’m trying to show only direct child categories of whatever category I’m currently on.

For example, in the screenshot sitemap below. On the “Automobiles” category page I only want to show the direct child categories which are “Trucks” and “Vans”. Right now it’s showing all the children which includes: “Trucks, Ford Trucks, Chevy Trucks, Vans, Ford Vans, Chevy Vans”

Is it possible to only show the direct children?

Here’s the screenshot of the sitemap.

Thanks,

Yes.

Set Parent to the current term ID.

Reference: Scroll down to “Terms Query” on Query Loop – Bricks Academy.

2 Likes

You’re a genius @Sridhar. I had the set the current term ID in the “Child of” instead of “Parent” and it wasn’t working.

Thank you!