Control what widgets your site’s visitors see, with custom visibility rules
With If Widget you can control on which pages widgets are shown. Show or hide widgets with custom visibility rules (no PHP or technical knowledge required).
The plugin is easy to use, each widget will have a new option “Show widget only if” which will enable the selection of visibility rules (example in Screenshots). Visibility rules can be combined with AND
/OR
to create even more personalised visibility options.
OR
Visitor is from USAND
Is not mobile deviceThese are the visibility rules you can add for widgets:
User is logged in
User is Admin or Editor
(plus all the available roles)User registration is allowed
Current post type is Post or Product
Current page is Front Page or Blog Page
Current URL starts/ends with "this-page"
Current URL contains with "keyword"
Is mobile device
Visitor is from US or Spain
✱Visitor language is English or Spanish
✱Show if user is in Group "Group Name"
, Show if user has Subscription "Example Subscription"
and more ✱The paid Add-on provides more visibility rules and priority support.
Visibility Rules: unlock all visibility rules like: visitor location, membership status, user groups and more. A few examples are marked with ✱ above.
Support: get one-on-one email support for any questions you may have about installing and configuring our plugins.
Get More Visibility Rules.
On Widgets editing page, each widget will have a section for controlling visibility. Enable the option “Show widget only if” to reveal and configure visibility rules (Example in screenshots).
New rules can be added by code in any other plugin or theme.
Example of adding a new custom rule for displaying/hiding a widget when current page is a custom-post-type.
// theme's functions.php or plugin file add_filter('if_visibility_rules', 'my_new_visibility_rule'); function my_new_visibility_rule(array $rules) { $rules['single-my-custom-post-type'] = array( 'name' => __('Single my-CPT', 'i18n-domain'), // name of the condition 'callback' => function() { // callback - must return Boolean return is_singular('my-custom-post-type'); } ); return $rules; }
WordPress provides a lot of functions which can be used to create custom rules for almost any combination that a theme/plugin developer can think of.