If Widget

⭐️4.8 (6)

Plugins | Site Design | Menus

If Widget

Control what widgets your site’s visitors see, based on custom visibility rules

1k active installations
Tested up to WP 5.4.2

← If Widget

Frequently Asked Questions

πŸ”—How can I enable custom visiblity for a widget?

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).

πŸ”—How can I add a custom visibility rule for menu items?

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;

πŸ”—Where can I find conditional functions?

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.


  • Version: 0.5
  • Last updated: 02 Mar 2019
  • Tested up to WordPress 5.4.2
  • Requires PHP 5.4 or higher
  • FAQ
  • Support forum ❐

Still need help?

Please visit the Support forum on WordPress.org