How to Use the Location Control


Features in this article require Block Visibility Pro

Control Overview

The Location control allows you to conditionally show or hide content based on where the block is located on your website and the attributes of its location. For example, you could limit block visibility based on a post’s categories and tags. Or you could display specific content depending on the author of the post.

This control was built with Full Site Editing in mind. If you are using a block-based theme that supports the upcoming Site Editor, you will be able to unlock the true potential of the Location control. Similarly, you can dynamically control widgets in the new block-based widget editor screen available in WordPress 5.8+.

Usage Examples

There are many applications for the Referral Source control. Here are a few examples to get you started.

  • Display unique calls to action or advertisements depending on a post’s category with the Post Taxonomy rule.
  • Assume your theme registers a sidebar widget area. Using the block-based Widget screen, display a related posts block on all posts but hide the block on other post types with the Post Type rule.
  • In the Site Editor or within a Query block, display a default featured image if the post does not have one set with the Featured Image attribute rule.
  • Using the Site Editor, display different navigation blocks depending on the current page of your website with the Post rule. For example, you could hide your main navigation on the checkout page of your online store. 
  • Using the Site Editor and the Archive rule, dynamically display a call to action in an archive template depending on a specific taxonomy. Say you have a post category called “Tutorials”. On the “Tutorials” archive page, create a banner to promote your video tutorials on YouTube. 

Configuration

How to Enable

Click on any block in the Block Editor and navigate to the Visibility panel in the Settings Sidebar. You will notice a vertical ellipsis icon in the Controls Toolbar. See the screenshot below. Click on the ellipsis, and all available visibility controls will appear. Select “Location” and the Location control panel will be added to the selected block.

Enabling the Location control in Block Visibility Pro.
Enabling the Location control in the block settings sidebar (v1.9)

How to Configure

Instructions are always better with examples. Let’s configure the block to be visible if the current post has category “Tutorials” AND the post was written by “Nick Diego”.

The Location control uses rules and rule sets to determine if the block should be visible. A thorough overview of each available rule is provided below.

Steps to Complete

  1. Navigate the Location control settings in the Visibility panel.
  2. Select “Post Taxonomy” from the rules selector.
  3. Choose “Category” from the taxonomy selector.
  4. Select “Is at least one of the selected” from the condition selector.
  5. Choose “Tutorials” from the terms selector.
  6. Click on the “Add rule” button to add a second rule.
  7. Choose “Author” from the rules selector.
  8. Select “Is any of the selected” from the condition selector.
  9. Choose “Nick Diego” from the authors selector.

The resulting configuration should resemble the screenshot below.

Configuring the Location control in Block Visibility Pro.
Configuring the Location control (v1.9)

Terminology & Notes

When working with the Location control, you will see many references to the term “post”, particularly in the rules detailed below. This can be confusing, so we want to clearly detail the terminology here. In short, “post” generally refers to any page, post, or custom post type on your site. Third-party plugins often add their own custom post types. For example, WooCommerce adds the products custom post type.

How to Disable

If you would like to disable the Location control at the block level, simply click on the vertical ellipsis icon in the “Controls” toolbar and deselect it. The control can also be disabled globally in the plugin’s Visibility Control Settings.

Note that if this control is disabled globally, any blocks that are actively being hidden by the Location control will become visible again.

Rules & Rule Sets

Similar to other controls in Block Visibility and Block Visibility Pro, the Location control is powered by rules and rule sets. All rules within a rule set must be satisfied for the selected block to be visible. However, you can also create multiple rule sets. Only one rule set needs to apply for the block to be visible. 

Within a rule set, you are creating AND conditions between multiple rules. Between two rule sets, you are creating OR conditions.

There are instances when rule errors can occur. For example, if rule inputs are not completely filled out or if the rule is based on a product that has since been deleted from your store. In these situations, the plugin defaults to showing the block unless other rules apply, which would hide the block.

Adding a rule to the Location control in Block Visibility Pro.
Location rules and rule sets in the block settings sidebar (v1.9)

Type Rules

The Type category currently only has one rule. In the future, expect more options that pertain to Full Site Editing such as rules based on templates and template parts.

Page Type

The Page Type rule should not to be confused with the Post Type rule detailed below. This rule allows you to conditionally display block content based on a set of conditionals that define how the current page is used and/or what it is.

The available conditions are:

  • Front Page (Homepage) – The page set in the WordPress admin Reading Settings.
  • Posts Page (Blog page) – The page set in the WordPress admin Reading Settings.
  • Singlular Page – Is the current page a single post?
  • Archive Page – Is the current page an archive?
  • Search Page – Is the current page a search results page?
  • 404 Page – Is the current page a 404 page?

Post Rules

The following rules pertain to post types, taxonomies, and individual posts. As a reminder, posts here refer to native posts, pages, and any custom post types on your website.

Post Type

This rule lets you conditionally display block content based on the post type of the current post. This rule shines when used in conjunction with page templates and template parts in the Site Editor.

Post Taxonomy

This rule lets you conditionally display block content based on the taxonomy terms of the current post. First, choose the taxonomy and then include or exclude individual taxonomy terms. For example, you would use this rule if you only wanted to show a block if the current post had a specific category.

If you are trying to display blocks only on taxonomy archives, use the Archive Type rule detailed below.

Post

This rule lets you conditionally display block content on specific posts. You first choose the post type and then include or exclude individual posts.

Post ID

This rule lets you conditionally display block content based on the ID of the current post. You can also set multiple IDs.

Attribute Rules

Attribute rules enable conditional block visibility based on a variety of post attributes. Does the post have comments? Is there a featured image set? Who is the post author? Is the post hierarchical, and does it have child posts? The list goes on… Let your creativity run wild!

Author

Display blocks based on the author of the current post.

Comments

This rule lets you conditionally display block content based on the existence or a specific number of user comments. The current options are: Post has comments, Post has no comments, and Comment count.

Display blocks based on whether the current post has a featured image or not. This rule is very useful in Query blocks and page templates. Imagine the situation where you need to display a default image if there is no featured image set.

Hierarchy

This rule lets you display content based on the hierarchy of the current post. The current options are Top level page (no parent), Parent page (has children), and Child Page (has parent). This rule pairs nicely with page templates. There are many situations where you may want to display specific blocks on child pages versus parent pages.

Supports

This rule lets you display content based on what the current post type supports. The current options are Comments, Excerpts, and Featured Images. This is a very handy rule to use in post templates or Query blocks.

Archive Rules

The Location control currently contains two rules for configuring archive-based conditional visibility. You will need to be using the Site Editor or the block-based Widget Screen to get the most out of these controls. Without the Site Editor or Widget Screen, it’s nearly impossible to position block content on archive pages. All the more reason to upgrade to a block-based theme.

Archive Type

This rule allows you to conditionally display block content on archive pages based on the archive type. Type includes the post types and taxonomies as well as author and date archives.

Archive

This rule provides more control than the Archive Type control detailed above. It lets conditionally display block content on archives based on individual taxonomy terms and specific authors.

Hide When Rules Apply

By default, the block will be visible if the applied rules are satisfied. Simply toggle the “Hide when rules apply” setting to hide the block instead.


Upgrade to Pro today!

Unlock block location controls, eCommerce integrations, advanced block scheduling, and more!