Jetpack Widgets: Visibility
The Widget Visibility is not a standalone widget that is activated in a Widget area.
This is a functionality that is added to all active widgets and it allows you to configure widgets to appear (or to be hidden) only on certain pages by using the Visibility panel.
In this article, we will show you how to enable Widget Visibility module and how to use the logical operators in its interface.
This module is now enabled by default. If you do not see the functionality described below, please visit Control Jetpack's Modules on One Page to learn how to activate it.
Click on Visibility button to open its interface:
First you must set the visibility status -
Visibility is controlled by several aspects: category, author, user, role, tag, date, page and taxonomy (with the number constantly increasing).
We also have a long list of criteria to build our conditional statement (notice the
Let's look at such example - we have contact page with a sidebar. As a page content we have a contact form, but we also have a contact widget in the sidebar and we do not want the same form to appear twice in the same page:
We are going to use the visibility module to hide the contact form in the sidebar when the contact page is displayed in the browser:
Click Save and refresh the contact page - there is no contact form in the sidebar:
We did not remove the contact widget from the sidebar, we just set an visibility rule.
On the pages other than Contact page which contain the same sidebar the contact form will appear as usual:
But we can add a new rule to hide the contact widget on blog pages also (click
+ to add rule or
x to remove it):
now we do not have a contact form in the sidebar:
If we select the option Match all conditions the logical operator
or will change to
and meaning the contact form will be hidden only if the conditions in all rules are met.
And because one page (the operator type) cannot be loaded as two separate pages in the same time (the criteria operators) both conditions are not met and the contact form will not be hidden in both pages.
Use page customizer to control widget visibility
Аll criteria operators are shown in one options list but actually they belong to different page templates. So you cannot select page as type operator and category as criteria because categories are assigned only to posts and not to pages. Such rule can be created but will not work.
We can manage the widget visibility in an easier and errorless manner if we open the page customizer from Appearance > Customize and click Widgets pane.
While we are browsing the site in the left sidebar we can see which widgets areas are supported in the corresponding page template.
If we stick with the contact form example, we can control the Contact widget visibility only on pages that support the Main Sidebar area by selecting the appropriate for that content type criteria operator.
So, first select the widget area where to place your widget and than select the appropriate type and criteria operators to create the visibility rule/s.