Conditional

The [su_conditional] shortcode displays its enclosed content only when a selected condition matches the current visitor or request. Use it for member-only messages, guest calls to action, role-specific instructions, scheduled announcements, device or language targeting, URL-based content, post context, cookies, and WooCommerce customer resources.

Description

Conditional is a wrapping shortcode. Select one condition, fill in the fields related to that condition, and place the content you want to control between the opening and closing shortcode tags. Text, HTML, and other shortcodes can be used inside it.

The default is operator displays the content when the condition matches. Set operator="is_not" to reverse the result.

Basic usage

[su_conditional condition="logged_in"]
  Welcome back! Here is your private content.
[/su_conditional]

Available conditions

Parameters

ParameterUsed withDescriptionValues / formatDefault
conditionAllSelects the rule that controls whether the enclosed content is displayed. Fields for other conditions are ignored.logged_in, logged_out, user_role, device, language, date, time, datetime, cookie, url, referrer, post_type, post_category, woocommerce_purchaseEmpty
operatorAllControls whether the selected condition is used directly or inverted.is, is_notis
roleuser_roleMatches when the logged-in user has any listed role.One or more role slugs separated by commas, for example administrator,editor.Empty
devicedeviceSelects the server-detected device type.mobile, desktopmobile
languagelanguageMatches the current WordPress locale.A locale such as en_US or a two-letter language code such as en.Empty
cookie_namecookieName of the cookie that must exist.A valid cookie name.Empty
cookie_valuecookieOptional exact cookie value. Leave empty to check only whether the cookie exists.Plain text.Empty
product_idwoocommerce_purchaseMatches when the logged-in customer bought any listed product.One or more numeric product IDs separated by commas.Empty
date_from
date_to
dateInclusive start and end date. Either boundary can be omitted.YYYY-MM-DD in the WordPress site timezone.Empty
time_from
time_to
timeInclusive daily start and end time. A range such as 22:0006:00 crosses midnight. Either boundary can be omitted.HH:MM in the WordPress site timezone.Empty
datetime_from
datetime_to
datetimeInclusive start and end date and time. Either boundary can be omitted.YYYY-MM-DD HH:MM in the WordPress site timezone.Empty
url_containsurlText that must occur in the current request URL.Plain text or a URL fragment.Empty
referrer_containsreferrerText that must occur in the optional HTTP referrer.Plain text or a URL fragment.Empty
post_typepost_typeMatches when the current post has any listed post type.One or more post type slugs separated by commas, for example post,page.Empty
categorypost_categoryMatches when the current post has any listed category.One or more category slugs or numeric IDs separated by commas.Empty

Examples

Show content to logged-out visitors

[su_conditional condition="logged_out"]
  Create a free account to access this resource.
[/su_conditional]

Target selected user roles

[su_conditional condition="user_role" role="administrator,editor"]
  Editorial note: please review this page.
[/su_conditional]

Schedule content by date and time

[su_conditional condition="datetime" datetime_from="2026-11-27 00:00" datetime_to="2026-11-30 23:59"]
  The weekend offer is live.
[/su_conditional]

Use a time range that crosses midnight

[su_conditional condition="time" time_from="22:00" time_to="06:00"]
  Night support is now available.
[/su_conditional]

Match a language

[su_conditional condition="language" language="en"]
  Read the English version of this guide.
[/su_conditional]
[su_conditional condition="cookie" cookie_name="plan" cookie_value="pro"]
  Thanks for being a Pro member.
[/su_conditional]

Show content on selected post types or categories

[su_conditional condition="post_type" post_type="post,page"]
  This note appears on posts and pages.
[/su_conditional]

[su_conditional condition="post_category" category="news,42"]
  Read the latest category update.
[/su_conditional]

Check a WooCommerce purchase

[su_conditional condition="woocommerce_purchase" product_id="123,456"]
  Download your customer resources.
[/su_conditional]

Invert a condition

[su_conditional condition="user_role" operator="is_not" role="administrator"]
  This notice is shown to users who are not administrators.
[/su_conditional]

Important notes

Developer API

Developers can register custom condition names with the shortcodes_ultimate_conditional_conditions filter and calculate their result with the shortcodes_ultimate_conditional_result filter.

add_filter(
  'shortcodes_ultimate_conditional_conditions',
  function ( $conditions ) {
    $conditions[] = 'front_page';
    return $conditions;
  }
);

add_filter(
  'shortcodes_ultimate_conditional_result',
  function ( $result, $condition, $atts ) {
    if ( 'front_page' === $condition ) {
      return is_front_page();
    }

    return $result;
  },
  10,
  3
);

The custom condition can then be used manually:

[su_conditional condition="front_page"]
  This content appears on the front page.
[/su_conditional]
Helpful?
🤝 Thank you!