Widget Options Documentation

Print

Conditional Display Logic

Are you in search of a practical widget management solution for your WordPress website? Look no further than our Widget Options plugin, designed to give you precise control over widget visibility using WordPress PHP conditional tags.

Key Features:

  1. Conditional Visibility: Customize widget visibility using PHP conditional logic functions, allowing you to tailor widget display based on specific conditions.
  2. Custom Conditions: Manage widgets effortlessly by applying custom conditions created through themes or other plugins, giving you the flexibility to control widget behavior according to your needs.
  3. Security Measures: It’s essential to note that content EVALs directly, similar to the Widget Logic Plugin. To address any security concerns, we’ve introduced optional filters called extended_widget_options_logic_override. These filters provide flexibility to enhance security and peace of mind by overriding content.

Here are a couple of examples of how it can be used:

  1. If you want to display information exclusively on tag pages, you can do so by using is_tag('your_tag') to display content on “your_tag” tag archive page.
  2. If you wish to display a widget on multiple pages that have the word “Bangkok” in their slugs, you can use strrpos($_SERVER['REQUEST_URI'], 'bangkok') to display the widget on posts or pages with “bangkok” in their slug or URL.
  3. If you want to show or hide using the display logic with an ACF field, you can use
    isset(get_field("field_name")) && get_field("field_name") == '1'
  4. If you are using BuddyBoss and want to show the widget only on your profile, you can use
    is_user_logged_in()&&( get_current_user_id() === bp_displayed_user_id() )
  5. If you are using BuddyBoss and want to show the widget on the other profile, you can use
    is_user_logged_in()&&( get_current_user_id() !== bp_displayed_user_id() )

To use conditional tags in Display Logic, follow these steps:

Step 1: Make sure to enable the “Display Logic” feature from the Widget Options settings.

Display Logic by Widget Options

Step 2: Go to “Appearance” > “Widgets” and navigate to widget you intend to use the conditional logic.

Step 3: Then hover to Widget Options tabs, click on magnifier glass tab and then click the Logic tab, input your preferred conditional tags. You can also explore our WP Conditional tags for more examples.

Step 4: Remember to save your changes by clicking the ‘Save’ button on the widget.

Display Logic Alternative

Widget Options has alternative feature called Slug Keyword Filter and URL & Wildcards Restrictions.

Slug Keyword Filter

This feature allows you to filter multiple pages based on keywords found in their slugs, separated by commas. It’s a handy tool for those who want to display widgets on pages with specific keywords in their URLs.

URL & Wildcards Restrictions

This feature will give you option to target specific URL to show or hide any widgets. You can use * as wildcard url, for example sample-page/* to target all subpages of “sample-page”.

Table of Contents
Take Full Control over your WordPress Widgets
Latest news from our blog: Your Ultimate Guide About WordPress Widgets Sidebar (February 29, 2024)