How to Query category's subcategories on a post page

I’m following up this thread, that found no success since 2022. Hope this time will be different. :slight_smile:

Imagine you have a structure of categories and subcategories. On the subcategory page you want to display a list of all of the other subcategories for your current category.

It looks like this:

  • Main category
    • Subcategory 1
    • Subcategory 2
    • Your category

How do you do that?

The obvious solution is to add a query, that will display categories of the main category. Like this:

That works well. But there are problems - the Parent parameter is static, not dynamic. And the query does not exclude itself from the loop.

I think the solution would be:

  • find a way to define the current category parent.
  • add it as a value into the parent filter.
  • define the current category id
  • exclude the id from the query.

Anyone already figured out?

Bump, anyone knows? :slight_smile: