How to Control Widget Visibility in WordPress with Jetpack?
Widgets are drag and drop elements that can be added to blog sidebar and footer sections of your WordPress site. WordPress comes with some default widgets like Text, Archives, Categories, etc and your theme and plugins can add additional widgets. You can view all available widgets in admin interface under "Appearance > Widgets" menu. Generally the widgets added to sidebar section will appear on all blog posts, archives, custom post types, pages, etc. Some users use multiple sidebars to add different widgets on different post types, but there is an easy way to control the widget visibility using Jetpack plugin.
What is Widget Visibility?
Widget visibility is one of the free module of Jetpack plugin which helps to control the visibility of individual widgets on different pages of your site. For example, you can show a search widget only on blog archive pages and hide it on sidebar of regular blog posts and pages.
How to Activate Widget Visibility?
Install Jetpack plugin and navigate to "Jetpack > Settings" menu. Search for the "Widget Visibility" module and activate it.
How to Use Widget Visibility?
Once the module is activated, navigate to "Appearance > Widget" and add the required widget to the sidebar. Let us take an example of "Search" widget, click on the "Visibility" button to see additional options as shown below:
Basically you will see three drop-down boxes to control the visibility of the "Search" widget on different pages.
1. Show or Hide - Choose you want show or hide the widget.
2. Choose the type from the drop-down. It can be a category, page, post type, taxonomy, etc.
3. Choose page from the drop-down.
The function can be used in different scenarios to hide and show the widget on different pages. For example, the "Search" widget can be shown on different pages like below:
- Hide on sidebar of all pages – “Hide” if “Page” is “Page”.
- Show on sidebar of only archive pages – “Show” if “Page” is “Archive Page”.
- Hide on archive page and show on blog posts – “Hide” if “Page” is “Archive Page” and “Show” if “Page” is “Post”.
You can also hide or show the widget for the posts belonging to specific category, taxonomy or tag.