5th Aug '25
/
0 comments

Conditionally Hide a Section on a Specific Taxonomy’s Term Archives in Bricks

A user asked:

I have a CTA in the footer of my site, which I have custom fields on various templates, etc to populate.

I don’t want it on a custom taxonomy archive (service-types), but I can’t for the life of me see how to hide that section on those alone.

CPT: service
Custom Taxonomy: service-type

Requirement: output a section everywhere except on taxonomy term archives of service-type.

This can be done by whitelisting the is_tax() WordPress function and using it with a dynamic data condition in Bricks.

Step 1

Whitelist the is_tax function.

Ex.:

<?php 

add_filter( 'bricks/code/echo_function_names', function() {
  return [
    'is_tax'
  ];
} );

You should also add other functions (native or custom) being used in your Bricks instance besides is_tax. This can be checked at Bricks → Settings → Custom code by clicking the Code review button.

More info on whitelisting can be found here.

Step 2

Edit your template having the section that you wish to not be displayed on the taxonomy term archive pages.

Add a dynamic condition like this:

{echo:is_tax(service-type)}

This will make the section be rendered everywhere except on the service-type term archives.

Get access to all 624 Bricks code tutorials with BricksLabs Pro

Leave the first comment

 

Related Tutorials..

Pro
Conditional Output in Bricks based on if Content has Headings

Conditional Output in Bricks based on if Content has Headings

How to prevent the output of the table of contents if the content has no headings.
Categories:
Tags:
Pro
Check If The Latest Post Was Published in The Last X Minutes

Check If The Latest Post Was Published in The Last X Minutes

In this Pro tutorial we shall define a custom function that takes in the number of minutes as an argument and returns true if there…
Categories:
Create A Customizable AJAX Add To Cart Button In Bricks Builder

Create A Customizable AJAX Add To Cart Button In Bricks Builder

In Bricks, you can simply create an Add To Cart button from a dynamic data / function {woo_add_to_cart}. This button supports AJAX as well if…
Checking for Post Type in Bricks

Checking for Post Type in Bricks

A way to output elements conditionally based on the current post type in the loop in Bricks.
Categories:
Pro
Conditional Rendering Based On Meta Box Group’s Sub Field

Conditional Rendering Based On Meta Box Group’s Sub Field

This Pro tutorial shows how we can output an element on a single post pages only if a specified sub-field (custom field created using Meta…
Pro
Query Variables Condition in Bricks

Query Variables Condition in Bricks

This Pro tutorial provides the steps to register a custom function that returns true or false depending on whether the current page URL has specific…