WordPress plugin for controlling widget visibility
If Widget is a WordPress plugin which adds extra functionality for widgets, making it easy to hide or display them based on visibility rules. Examples:
User is logged in
visiting from mobile device
Admins and Editors
The plugin is easy to use, each widget will have a “Show widget only if” option which will enable the selection of visibility rules.
This repo is used only for development, downloading & installing from here won’t work as expected. Install from WordPress.org plugin page
User is logged in
Admin
Editor
Author
etcFront page
Blog page
Post
Page
Product
etcIs Mobile
User is logged in
AND Device is mobile
User is Admin
AND Is Front Fage
Custom visibility rules can be added easily by any plugin or theme.
Example of adding a new 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;
}
Head over to plugin’s page on WordPress.org for more info, reviews and support.