开发者 | andreiigna |
---|---|
更新时间 | 2021年1月18日 18:49 |
PHP版本: | 5.6 及以上 |
WordPress版本: | 5.6 |
版权: | GPL-3.0-or-later |
版权网址: | 版权信息 |
AND
/OR
to create even more personalised visibility options.
Examples
OR
Visitor is from USAND
Is not mobile deviceUser 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 ✱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.