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.

Result:

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

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

bricks/posts/merge_query Explained

bricks/posts/merge_query Explained

This short article provides details on Bricks' bricks/posts/merge_query filter. On pages rendered by an archive or search template, secondary queries like the ones used for…
Categories:
Tags:
Pro
Setting a Bricks template for Parent pages

Setting a Bricks template for Parent pages

This Pro tutorial shows how bricks/active_templates filter can be used to programmatically assign a Bricks template to all singular pages (of any post type) that…
Pro
Restrict Content Pro in Bricks

Restrict Content Pro in Bricks

This Pro tutorial provides the steps to restrict Pages and individual elements like Sections in Bricks depending on whether the current user has any active…
Modifying ACF Field Value Before It Is Output

Modifying ACF Field Value Before It Is Output

Consider the scenario where a Page has a "Page Fields" field group created with ACF Pro like this: Field name: scientific_coordinators (type Repeater)|__ Sub field…
Categories: