Query Loops

Filtering

Query filters narrow a query loop before TemplateX repeats the HTML for each result.

Field Filters#

Use field:condition="value" on the opening query tag.

  • {{ query:project featured:is="true" }}
  • {{ query:project featured:is="true" location:is="amsterdam" }}
  • {{ query:project location="amsterdam" }}

If you omit the condition, TemplateX uses is.

Multiple filters are combined together. The post must match all of them.

Conditions#

  • is: matches the exact value, such as featured:is="true".
  • isnt: does not match the value, such as location:isnt="remote".
  • contains: contains the text somewhere in the value, such as summary:contains="Laravel".
  • starts_with: starts with the text, such as sku:starts_with="TX".
  • is_after: is later than the date, such as event_date:is_after="2025-01-01".
  • is_before: is earlier than the date, such as event_date:is_before="2025-12-31".

Dynamic Values#

Use single braces when the comparison value should come from the current context.

  • {{ query:posts title:is="{slug}" }}
  • {{ query:posts slug:is="{parent.slug}" }}
  • {{ query:posts featured:is="{is_featured}" }}
  • {{ query:posts taxonomy:category="{slug}" }}

Do not use double brackets inside query attributes. Use title:is="{slug}", not title:is="{{ slug }}".

Taxonomy Filters#

Use taxonomy:{taxonomy}="slug" when the query should match WordPress terms.

  • {{ query:posts taxonomy:category="news" }}
  • {{ query:posts taxonomy:post_tag="bread" }}
  • {{ query:posts taxonomy:post_tag="bread|recipe" }}
  • {{ query:project taxonomy:project_type="web" }}
  • {{ query:posts taxonomy:category="{slug}" }}

category is the built-in WordPress category taxonomy. post_tag is the built-in tag taxonomy. Custom taxonomies use their real taxonomy slug.

Native WordPress Fields#

  • title: native post title. Supports is, isnt, contains, and starts_with.
  • slug: native post slug. Supports is, isnt, contains, and starts_with.
  • date: native post date. Use date:is_after="2025-01-01" or date:is_before="2025-12-31".
  • status: native post status, such as status:is="draft".
  • published: shortcut for published posts, such as published:is="true".

ACF And Custom Fields#

Other field names are treated as custom fields. That includes simple ACF fields, because ACF stores their values as post meta.

Good fits:

  • ACF True/False fields: featured:is="true".
  • ACF Select and Radio Button fields: event_type:is="workshop".
  • ACF Text, Text Area, Email, URL, and WYSIWYG fields: summary:contains="Laravel".
  • ACF Number fields: price:isnt="99".
  • Date-like custom fields stored in a consistent date format: event_date:is_after="2025-01-01".
  • Any custom meta key that stores one clear value per post.

Be careful with complex ACF fields such as Repeater, Flexible Content, Gallery, Group, Relationship, Post Object, User, Checkbox, and multi-select fields. Those fields can store arrays, IDs, or serialized values, which are harder to query cleanly. If you need to filter by that kind of data often, a taxonomy or a simple helper field is usually clearer.