WordPress widgets are used to add extra features or functionality to your theme. They are added to your theme sidebars or widget areas, including footer and after post areas. Some of the widgets are included with the theme, such as Recent Posts or Search widgets, and others you or your website developer will add using plugins. They can include videos, email newsletter signups, social media follow, recent posts, display your Instagram images, a brief about you, shopping carts, and calls-to-action, almost any functionality.
So you’ve added some cool widgets to your sidebar or footer. What happens when you don’t want to show one of them on a particular page? What if you want to hide sidebar widgets on some WordPress pages and posts? Or what if you want to show a different widget, depending on the post category?
Let’s use the examples to show a different widget depending on the post category. We’ll look at three different plugins.
One of my favorite widget visibility plugins is Widget Options – Add Context To WordPress Widgets; it is understandable and versatile too. There is a settings page that allows for controlling other options too, such as hiding the title. This plugin displays selections for showing the widget on posts with categories – Genesis Tutorials and Miscellaneous. See more on this plugin in the comment below from one of the plugin authors, Jeffrey Carandang.
Jetpack Widget Visibility
If you use Jetpack, there is a Widget Visibility module that is included with the Jetpack plugin. The selections make it super easy for anyone to make the right choices to show or hide sidebar widgets for a particular category, by clicking the Visibility button near the blue Save button at the bottom of the widget. For instance this image has the selections to show the widget on posts in Category #1 and Category #2. You can use the Add links to add more categories or pages.
If you’re a developer or understand WordPress conditional statements, you can use the plugin Widget Logic to write the conditional statement to show or hide the sidebar widgets. It is located just below the widget, as the others are. But since this plugin takes PHP code, it’s not a plugin for most users. This example uses the category IDs 24 and 25 to show the widget for posts and archives in Category #1 and Category #2.
There are other plugins to show or hide sidebar widgets, but these are the easiest or most versatile for me. A final mention is Content Aware Sidebars. This is more than a widget visibility plugin though, and allows for different sidebars on different page or post types.