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.
Jetpack Widget Visibility
My favorite plugin to use is the 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 don’t use Jetpack, Restrict Widgets is a good choice to hide sidebar widgets; it is understandable and versatile too. Again it displays selections for showing the widget on Category #1 and Category #2 posts.
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.