Prefiltering Bricks Terms Query Loop

Let's say there's a Events CPT with a 'Event Year' custom taxonomy.

Sample event year names could be: 2021, 2022, 2024, 2025, 2028 etc.

We can set up a Terms query in Bricks to output these terms.


The reason 2021 is not present is because there are no posts that have been categorized with 2021.

Now the requirement is to output only the (non-empty) years that are in the future.

Like this:

This Pro tutorial shows how terms can be filtered based on their value using the bricks/terms/query_vars filter.

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

Instant access to 390+ Bricks code tutorials with BricksLabs Pro