🚀 🚀 LAUNCH SALE - 33% off all Lifetime Licenses

Term Query

Last Modified: October 26, 2026

Use Term Query to display category, tag or custom taxonomy terms instead of posts. Each loop item receives its own term context, so a title and archive link can point to the right term.

In WordPress, a term is a single category, tag, or whatever taxonomy it is. A taxonomy is “An ordered arrangement of groups or categories” (i.e. something you use to group things somehow). WordPress includes two taxonomies out of the box: Categories and Tags.

As such, this loop will allow you to display a list of terms inside one or more taxonomies. This can be helpful in a number of ways:

  • Creating a list of categories or tags
  • Displaying a list of categories and posts inside those categories (requires a nested Post Query)
  • And more

Like all other query types, the Term Query is a variation of the GenerateBlocks Query block. In simple terms, this just means it’s a Query block with a bunch of preconfigured options to make it easier to work with. This means it works just like the Query block does and has a number of very similar qualities/features.

Options

The Term Query uses WP_Term_Query under the hood and supports all of it’s arguments.

A few params are visible by default, but if you click Add parameter you can choose from the full list.

Parameters

  • Taxonomies (required)
    • Choose the taxonomy or taxonomies whose terms you want.
  • Terms per page (default: 10)
    • Equivalent to “posts per page” in a Post Query. Use -1 to get all terms (use this with caution, see Best Practices below).
  • Hide empty terms excludes terms without posts; it starts on.
  • Order by
  • Order
    • Ascending, Descending, or “Include Order”
    • Include Order works with the chosen Include terms list.
  • Include terms
    • Only includes the chosen terms in the query results. Use this to choose very specific terms to display.
  • Exclude terms
    • Prevent specific terms from showing in the query results
  • Include terms from these posts
    • Get all of the terms (categories, tags, etc) associated with the posts you’ve chosen. Uses the query’s Taxonomies to find the terms.
  • Search
    • Equivalent of using the WordPress search. Helpful to search terms by name (ex: some prefix the term names you want all share).
  • Parent term
    • Returns direct children of one term.
  • Child of
    • Get all children of a given parent term with no depth limit. This is ignored if Parent Term is set.
  • Include hierarchy
    • This is on by default so the only reason you’ll use it is to disable the behavior (uncommon). This is used if you are trying to hide empty terms and you want to make sure child terms don’t show if the parent is empty.
  • Childless only
    • Only include terms with no child terms.
  • Pad counts
    • Makes each term’s count include the counts of its descendants, rather than only objects assigned directly to that term. It’s useful when displaying hierarchical taxonomies. Example: a parent category’s count can reflect posts in its child categories too.
  • Offset skips the specified number of terms.
  • Meta Query
    • Filters users by metadata key and optional value, comparison and type; use multiple clauses when needed.
    • Only include as many clauses as you need (see Best Practices below).

Using Query Preview

GB Query Enhancements, GenerateBlocks, and WordPress core all have a number of filters that can affect query parameters and results. The Query preview shows you what the final result is so you can get a clear picture of what parameters are in use.

To open the query preview:

  1. Select the Query block
  2. Open the block sidebar (right side of the editor) and look for a link titled: “View query PHP”.
  3. Click this and a modal will appear with the preview.

Examples

Use a post, page, or template that accepts blocks. The taxonomy picker is multiselect: remove a selected chip before switching taxonomies. Leave Hide empty terms on (the default) and assign content to the terms you want to show. Save, close, and reopen the editor before checking the front end.

List of post categories

Prerequisites: Create post categories and assign posts to them. Add descriptions if you want those shown.

  1. Type /term query, choose Term Query from the inserter. Choose the Name & Description template.
  2. Select the parent Term Query. Categories (the WordPress category taxonomy) is already selected by default. Keep its chip; close the dropdown. If you reopen it and see another Categories option, that is the unrelated GB Pro overlay taxonomy, not the one to add.
Term Query inspector showing Categories selected and Hide empty terms enabled
Categories stays selected; Hide empty terms is on.
  1. Keep the heading {{term_title link:term}} and paragraph {{term_description}} supplied by the template. Leave Terms per page at 10 and Hide empty terms on.
  2. Save and reopen the editor.

Expected result: Each non-empty post category appears with its description and its own archive link. The query includes all matching categories on the site, not just those created for this example.

Four category archive links; Guides, Releases, and Tutorials have descriptions
Category archive links and descriptions.

List of tags with a “#” prefix

Prerequisites: Create tags and assign each to a post.

  1. Insert Term Query with /query, then select Name & count.
  2. Select the parent query. Remove the default Categories chip, then choose Tags (post_tag). Leave Terms per page at 10 and Hide empty terms on.
Term Query inspector showing Tags selected and Hide empty terms enabled
Tags is the only selected taxonomy.
  1. In the Loop Item, select the linked Text block containing {{term_title}} and type a literal # before it: #{{term_title}}.
Text block with a literal hash before the term title token and a term archive link
The literal # precedes the term title token.
  1. Keep its Link destination as {{term_archive_url}} and the adjacent count block as {{term_count}}. Save and reopen.

Expected result: Each #-prefixed tag links to its own tag archive and appears beside its count. The prefix is saved in the Text block, not supplied by CSS or PHP.

Hashtag links for blocks, queries, and workflow beside their counts
Tag links and counts.

List of WooCommerce Brand Logos

Prerequisites: WooCommerce 9.6+ includes built-in Product brands. Add a thumbnail to each brand and assign products to brands. Tested locally with WooCommerce 11.2.1, GenerateBlocks 2.5.0, GenerateBlocks Pro 2.8.0 and GB Query Enhancements 1.4.0. This example uses Product Category Image URL to read each brand’s image on those versions.

  1. Insert Term Query with /term query, choose Start blank, remove the default Categories chip, and choose Product brands (product_brand). Leave Terms per page at 10 and Hide empty terms on. Brands without assigned products may not appear; turn Hide empty terms off only if you intentionally want unassigned brands too.
Term Query inspector showing Product brands selected and Hide empty terms enabled
Product brands is the only selected taxonomy.
  1. Inside the Loop Item, add the Image block whose inserter description reads “A self-closing media element.” That is GenerateBlocks generateblocks/media, not the other Image block (“Insert an image to make a visual statement.”). If previews repeat, select the single authored Image in List View under Term Query → Looper → Loop Item.
  1. In the Image block’s Image field, click the Dynamic tags icon, choose Product Category Image URL, leave Source: Current Post and Required to render unchanged, then insert {{product_category_image_url}}.
Dynamic Tags dialog with Product Category Image URL, Source Current Post, and Required to render checked
Product Category Image URL with Source: Current Post and Required to render unchanged.
  1. Set Link to {{term_archive_url}} and Alt text to {{term_title}} logo. Link attributes → href is populated automatically from Link; do not add a second href by hand.
Image inspector showing the product category image token and term archive link
The Image source and Link fields in the inspector; alt text is set separately.
  1. Save and reopen. The editor preview may be blank even when the saved fields are correct; inspect the front-end images.

Expected result: On the tested versions, each brand has its own thumbnail, link to its own brand archive, and term-specific alt text.

Three different synthetic brand logos linked to their brand archives
Three linked, distinct synthetic brand images.

Best Practices

I’ve included some helpful tips and best practices to make the most out of the Term Query. Some of these things are applicable even if you’re using PHP and not using blocks to do queries at all!

  • Avoid complex term meta queries with many clauses. The more meta query clauses you add, the slower the query becomes. This isn’t always a problem, but you should be careful to not overwhelm your server with a low query.
  • Avoid using a -1 value for Per Page. This can be fine if you have a small number of terms, but on sites with many terms, this can cause a lot of excessive server usage.