1. Home
  2. Docs
  3. Divi Extended Loop
  4. Settings
  5. Taxonomy Queries

Taxonomy Queries

Using Tax Queries in Loop Customization

Tax Queries allow you to filter posts based on taxonomy terms such as categories, tags, or custom taxonomies. This is essential for building dynamic content layouts that respond to specific term selections—like showing posts from selected categories or filtering by custom labels.

How Tax Queries Work

Each tax query defines a set of conditions that must be met for a post to be included in the loop. You can add multiple tax queries and control how they interact using a relation operator.

1. Relation (AND / OR)

This dropdown determines how multiple tax queries are evaluated:

  • AND – All tax queries must match for a post to be included.
  • OR – A post will be included if it matches at least one tax query.

2. Taxonomy

Select the taxonomy you want to filter by. Common options include:

  • Categories – Standard WordPress post categories.
  • Tags – Standard WordPress post tags.
  • Custom Taxonomies – Any registered taxonomy (e.g., product_type, portfolio_category).

3. Terms

Choose one or more terms from the selected taxonomy. These are the values used to filter posts. You’ll typically see term names and their corresponding IDs listed for reference.

Example selected terms:

  • Magni sequi distinctio (ID: 8)
  • Itaque (ID: 6)

4. Operator

This dropdown defines how the selected terms are used in the query:

  • IN – Include posts that match any of the selected terms.
  • NOT IN – Exclude posts that match the selected terms.
  • AND – Include posts that match all selected terms simultaneously.

5. Add or Remove Tax Queries

You can add multiple tax query blocks using the Add Tax Query button. Each block can be removed individually with the Remove button, allowing for flexible and layered filtering.

Use Cases

  • 🗂️ Display posts from specific categories (e.g., “News” and “Tutorials”).
  • 🚫 Exclude posts tagged with “Archived” or “Deprecated”.
  • 🎯 Filter products by multiple custom taxonomy terms (e.g., “On Sale” and “Featured”).

Tips

  • Use AND relation to create highly specific filters across multiple taxonomies.
  • Use NOT IN to exclude unwanted content from loops.
  • Combine tax queries with date filters or custom field sorting for advanced layouts.

How can we help?

Submit a Comment