27th Jun '25
/
0 comments

How to Query WordPress Taxonomy Terms by Hierarchy Level in Bricks

This Pro tutorial provides the steps to limit the terms of a Bricks Terms query to only those at a specific level within the taxonomy hierarchy.

Consider this WooCommerce product categories hierarchy:

After implementing the tutorial we can output all terms in level 1 or 2 or 3 etc.

Terms in level 1 (note this is also possible w/o any custom code):

Terms in level 2:

Terms in level 3:

Step 1

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Latest Featured Posts First in Bricks Query Loop (No Duplicates)

Latest Featured Posts First in Bricks Query Loop (No Duplicates)

In the Bricks Facebook group a user asks: We can use AI to help unfreeze our brains sometimes or at least have it write the…
Categories:
Pro
WordPress Posts using WP REST API in Bricks

WordPress Posts using WP REST API in Bricks

The steps to display posts from any WordPress site that has WP REST API enabled in Bricks builder using a custom query type.
Categories:
Querying Posts by Date Field to Exclude Past Events with ACPT Plugin

Querying Posts by Date Field to Exclude Past Events with ACPT Plugin

In the Bricks' Facebook group, a user asked: Meta query? What am I missing?Hi all, really need a little guidance on this one. I have…
Categories:
Pro
6 Random Featured Posts in Alphabetical Order in Bricks

6 Random Featured Posts in Alphabetical Order in Bricks

How to output x number of random posts with a specific meta value set, in Alphabetical order.
Categories:
Pro
Related Posts by Taxonomy in Bricks

Related Posts by Taxonomy in Bricks

In the previous Posts Related by Current Post's Terms in Bricks tutorial, we showed how posts related to the current single post that have the…
Categories:
Bricks Query Loop – Posts Authored by Logged in User

Bricks Query Loop – Posts Authored by Logged in User

How to display only the posts authored by the currently logged-in user in a query loop.
Categories:
Pro
How to Insert Element(s) Between Query Loop Posts in Bricks

How to Insert Element(s) Between Query Loop Posts in Bricks

Update on 16 Aug 2023: Follow this tutorial instead. This Pro tutorial shows how we can insert a Div (or any custom HTML) after nth…