14th Mar '25
/
0 comments

Conditionally Rendering an Element Outside the Loop based on Taxonomy Term in Bricks

A user asks:

Hiding element based on taxonomy

I have an element in a footer that I want to hide if a page has a particular taxonomy value.

Consider this scenario:

Taxonomy key: page-type for page post type.

A specific Page, say a Page titled "Sample Page" has the Page Type set to "No Ad".

The requirement is to output an element (an ad) in the site's footer (or can be in the site header) i.e. outside the loop through out the Bricks site except on Pages whose page type taxonomy has "No Ad" assigned to them.

Here's how this can be done:

Step 1

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 626 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Custom Dynamic Data Tags in Bricks

Custom Dynamic Data Tags in Bricks

A user asks: Hiding element based on taxonomy I have an element in a footer that I want to hide if a page has a…
Pro
Custom Conditions in Bricks Builder

Custom Conditions in Bricks Builder

Updated on 22 Jun 2022 This Pro tutorial is a continuation of the previous Conditions in Bricks Builder tutorial. We are going to keep updating…
Categories:
Pro
Conditional single post Bricks template based on internal referrer URL

Conditional single post Bricks template based on internal referrer URL

How to automatically select a single post template depending on the page from which the post is accessed.
Pro
Checking if the current Page/Post has Children i.e. is a Parent in Bricks

Checking if the current Page/Post has Children i.e. is a Parent in Bricks

Shows how we can check whether the current Page or Post (of any hierarchical post type) is a parent
Categories:
Pro
Conditional Rendering of ACF Repeater Rows Based on True / False Sub Field in Bricks

Conditional Rendering of ACF Repeater Rows Based on True / False Sub Field in Bricks

This Pro tutorial provides the steps to modify a ACF Repeater query loop to only output the rows for which a True / False type…
Categories:
Pro
At Least 1 Search Result Condition in Bricks

At Least 1 Search Result Condition in Bricks

Registering a custom condition to render elements depending on whether there is at least one search result.
Categories:
Dynamic Data :value filter in Bricks

Dynamic Data :value filter in Bricks

Bricks 1.5.7 introduced a new :value dynamic data filter. This tutorial provides a practical example of how this filter can be used. Meta Box Checkbox…
Categories: