Query Terms
This page covers how to query taxonomy terms — categories, tags, and custom taxonomies.
Basic usage
Paste this directly into the query arguments editor in the Loop block's sidebar:
[
'taxonomy' => 'category',
'number' => 10,
'orderby' => 'name',
]
Common arguments
Arguments follow the WP_Term_Query API — any argument it accepts works here too.
| Argument | Description | Example |
|---|---|---|
taxonomy | Taxonomy name | 'category', 'post_tag' |
hide_empty | Hide terms with no posts | true, false |
orderby | Sort field | 'name', 'count' |
order | Sort direction | 'ASC', 'DESC' |
number | Limit results | 10 |
parent | Parent term ID, 0 for top-level | 0 |
child_of | All descendants of a term | 12 |
include | Include specific IDs | [1, 2, 3] |
exclude | Exclude specific IDs | [4, 5] |
slug | Filter by slug(s) | 'news' |
More query examples
Category navigation
[
'taxonomy' => 'category',
'hide_empty' => true,
'orderby' => 'name',
]
Top categories by post count
[
'taxonomy' => 'category',
'orderby' => 'count',
'order' => 'DESC',
'number' => 5,
'hide_empty' => true,
]
Top-level product categories
[
'taxonomy' => 'product_cat',
'hide_empty' => true,
'parent' => 0,
]
Tag cloud
[
'taxonomy' => 'post_tag',
'orderby' => 'count',
'order' => 'DESC',
'number' => 20,
'hide_empty' => true,
]
Child terms of a parent
Use in a nested Loop block where parent is the outer loop's data alias:
[
'taxonomy' => 'location',
'parent' => parent.id,
]
Template examples
In the HTML inspector, the Loop block uses get_terms() syntax. Query arguments are managed by the sidebar — the inspector shows get_terms() with empty parentheses to keep the template readable.
Category filter with active state
<nav class="filter-bar">
<a href="/blog/" class="{{ not archive.term ? 'active' : '' }}">All</a>
{% for term in get_terms() %}
<a href="{{ term.link }}" class="{{ archive.term.id == term.id ? 'active' : '' }}">
{{ term.name }}
</a>
{% endfor %}
</nav>