Skip to content
Advertisement

WordPress: Get child taxonomies only from one level down

I want to display the WooCommerce sub-categories based on the current categorie ID.

To get all sub-categories, I’m using the following code to get all child IDs. The problem is, that I get all levels below the current category.

Is there any way to limit the categories to only the next level? For example: Level 1 only gets categegories from leven 2 and level 2 only from level 3.

Here’s my code (it’s from the WordPress docs):

JavaScript

Advertisement

Answer

As taken from https://wordpress.stackexchange.com/a/124429

You could do

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement