How to Use Conditional Display


This feature is only available in Stackable Premium

What is Conditional Display

Conditional Display allows you to assign conditions to every block, which when fulfilled will show or hide the block in the frontend.

You have the option to:

  • Assign whether to hide or show any block when the conditions are met
  • Use one or multiple conditions together for more complex needs
  • Choose whether ALL or ANY of your conditions should be met before showing a block

Current supported conditions:

  • Login Status
  • Role
  • Date & Time
  • Custom PHP
  • Conditional Tag
  • Query String
  • Post Meta
  • Site Option
  • Post IDs
  • Post Type
  • Post Taxonomy

How to Use Conditional Display

Select your chosen block, and navigate to the Advanced Tab in the inspector where you will see the Conditional Display tab.

Once you click on the Conditional Display tab, you will see the Visibility settings where you can choose between hiding or showing your block when the conditions are met.

If you want to add a condition, just click on the Add New Condition button, and a Condition Type section will appear. This is where you can select from our various supported conditions.

You can add as many conditions as you'd like and assign whether ALL of the conditions should be met, or ANY one of them.

Supported Conditions

Login Status

If you set this as the condition type, the block will be displayed or hidden depending on whether the users are logged in or logged out.

Role

If you set this as the condition type, the block will be displayed or hidden depending on the role assigned to them in the Role Manager (e.g. Administrator, Editor, Author, and more.)

Date & Time

If you set this as the condition type, the block will be displayed or hidden on the selected days.

Custom PHP

You can create your own logic here using PHP, and when the condition is fulfilled then that can be used to display or hide the block.

For example, you can use this to display or hide the block if the current page has a specific post meta value:

get_post_meta( get_the_ID(), 'key', true ) !== false

Or, if you want to display the block only if there is a Featured Image, you can just add this code:

has_post_thumbnail() !== false

Conditional Tag

You can use WordPress conditional tags such as is_page() or is_singular() to decide whether the block will be displayed or hidden.

Query String

You can enter one query string per line here. The block will be displayed or hidden if any of the query strings found in the current URL match. For example, using variable=value will match if your URL is **http://mywebsite.com/?variable=value**

Post Meta

If you set this as the condition type, the block will be displayed or hidden based on the value of the current page’s post meta data. You can set the matching if the post meta data doesn’t exist, or matches a specific value or condition.

Site Option

If you set this as the condition type, the block will be displayed or hidden depending on the value of a site wide option (code-wise, this is a call to the get_option function)

Post IDs

If you set this as the condition type, the block will be displayed or hidden if the current post’s ID matches one of the Post ID/s you entered.

Post Type

If you set this as the condition type, the block will be displayed or hidden depending if the current post has the Post Type you entered.

Post Taxonomy

If you set this as the condition type, the block will be displayed or hidden depending if the current post has the Post Taxonomy you entered. You have the option to select the Post Type and Taxonomy Type (Categories or Tags).