Show and hide widgets on specific posts, pages and sections of your site.
Use Widget Context to show and hide widgets on certain sections of your site — front page, posts, pages, archives, search, etc. Use targeting by URLs (with wildcard support) for maximum flexibility.
Premium Support
Subscribe to our Premium Support service and get the PRO π version of the plugin for free when itβs launched! Your support enables consistent maintenance and new feature development, and is greatly appreciated.
Widget visibility can be configured under individual widget settings under “Appearance β Widgets” in your WordPress administration area or through the widget editing interface in the Customizer.
Target by URL
The “Target by URL” is a powerful feature for targeting sections of your website based on the request URLs. It was inspired by a similar feature in the Drupal CMS.
Use relative URLs such as page/sub-page instead of absolute URLs https://example.com/page/sub-page because relative URLs are more flexible and make the logic portable between different domains and server environments.
Wildcards
Use the wildcard symbol * for matching dynamic parts of the URL. For example:
topic/widgets/* to match all posts in the widgets category, if your permalink structure is set to /topic/%category%/%postname%.
page-slug/* to match all child pages of the page-slug parent page.
Use a trailing ?* to capture URL with all query arguments such as utm_source, etc. For example, for every blog/post-slug also include blog/post-slug?*.
Exclude by URL
Specify URLs to ignore even if they’re matched by any of the other context rules. For example, enter example/sub-page to hide a widget on this page even when “All Posts” is selected under “Global Sections”.
Installation
Search for Widget Context under “Plugins β Add New” in your WordPress dashboard.
Widget Context settings will appear automatically under each widget under “Appearance β Widgets”.
Visit “Settings β Widget Context” to configure the available widget visibility contexts.
Screenshots
Widget Context settings at the bottom of every widget
Widget Context plugin settings
Changelog
1.3.2 (April 27, 2020)
Bugfix: Fix the Widget Context settings link in the widget controls after moving the settings under the “Appearance” menu for usability (closer to the widget settings).
Feature: Add a link to the plugin settings in the plugin admin list, too.
1.3.1 (April 24, 2020)
Bugfix: better support for URL rules with query parameters.
1.3.0 (April 23, 2020)
Introduce the long-awaited “Exclude by URL” feature to prevent certain URLs from showing or hiding a widget when it’s matched by any other visibility rule.
Introduce premium support to help maintain the plugin. Subscribe now to get the PRO version of the Widget Context for free when it’s launched!
1.2.0 (August 20, 2019)
Set PHP 5.6 as the minimum supported version of PHP to match WordPress core.
Developer tooling update: introduce PHP autoloading, PHP unit tests with proper mocking, linting for JS, switch to Docker inside a Vagrant wrapper for local development environment and update to the latest version of WordPress coding standards (see #50).
1.1.1 (June 9, 2019)
Mark as tested with WordPress 5.2.
Add test coverage reporting and remove Debug Bar integration since it wasn’t complete. Refactor plugin structure to support dependency integration. See #47.
Confirm that the plugin works with the latest version of WP.
0.7
Bug fix: check for active sidebars only after $paged has been set.
0.6
Don’t check for used sidebars on each widget load. Allow absolute URLs in the URL check.
0.5
Added distinction between is_front_page() and is_home(). Remove widgets from wp_get_sidebars_widgets() if they are not being displayed — this way you can check if a particular sidebar is empty.
0.4.5
Widget output callback couldn’t determine the widget_id.
0.4.4
Fixed widget control parameter transfer for widgets that don’t use the new widget api.