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.
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.
[su_conditional condition="logged_in"]
Welcome back! Here is your private content.
[/su_conditional]
logged_in — the visitor is logged in.logged_out — the visitor is not logged in.user_role — the current user has any of the specified WordPress roles.device — WordPress identifies the request as mobile or desktop.language — the current locale matches a full locale or two-letter language code.date — the current date is inside an inclusive date range.time — the current time is inside an inclusive daily time range.datetime — the current date and time is inside an inclusive range.cookie — a named cookie exists and, optionally, has an exact value.url — the current request URL contains the specified text.referrer — the HTTP referrer contains the specified text.post_type — the current post has any of the specified post types.post_category — the current post has any of the specified categories.woocommerce_purchase — the logged-in WooCommerce customer bought any of the specified products.| Parameter | Used with | Description | Values / format | Default |
|---|---|---|---|---|
condition | All | Selects 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_purchase | Empty |
operator | All | Controls whether the selected condition is used directly or inverted. | is, is_not | is |
role | user_role | Matches when the logged-in user has any listed role. | One or more role slugs separated by commas, for example administrator,editor. | Empty |
device | device | Selects the server-detected device type. | mobile, desktop | mobile |
language | language | Matches the current WordPress locale. | A locale such as en_US or a two-letter language code such as en. | Empty |
cookie_name | cookie | Name of the cookie that must exist. | A valid cookie name. | Empty |
cookie_value | cookie | Optional exact cookie value. Leave empty to check only whether the cookie exists. | Plain text. | Empty |
product_id | woocommerce_purchase | Matches when the logged-in customer bought any listed product. | One or more numeric product IDs separated by commas. | Empty |
date_fromdate_to | date | Inclusive start and end date. Either boundary can be omitted. | YYYY-MM-DD in the WordPress site timezone. | Empty |
time_fromtime_to | time | Inclusive daily start and end time. A range such as 22:00–06:00 crosses midnight. Either boundary can be omitted. | HH:MM in the WordPress site timezone. | Empty |
datetime_fromdatetime_to | datetime | Inclusive start and end date and time. Either boundary can be omitted. | YYYY-MM-DD HH:MM in the WordPress site timezone. | Empty |
url_contains | url | Text that must occur in the current request URL. | Plain text or a URL fragment. | Empty |
referrer_contains | referrer | Text that must occur in the optional HTTP referrer. | Plain text or a URL fragment. | Empty |
post_type | post_type | Matches when the current post has any listed post type. | One or more post type slugs separated by commas, for example post,page. | Empty |
category | post_category | Matches when the current post has any listed category. | One or more category slugs or numeric IDs separated by commas. | Empty |
[su_conditional condition="logged_out"]
Create a free account to access this resource.
[/su_conditional]
[su_conditional condition="user_role" role="administrator,editor"]
Editorial note: please review this page.
[/su_conditional]
[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]
[su_conditional condition="time" time_from="22:00" time_to="06:00"]
Night support is now available.
[/su_conditional]
[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]
[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]
[su_conditional condition="woocommerce_purchase" product_id="123,456"]
Download your customer resources.
[/su_conditional]
[su_conditional condition="user_role" operator="is_not" role="administrator"]
This notice is shown to users who are not administrators.
[/su_conditional]
device condition uses WordPress server-side request detection. It does not react to the browser viewport width and should not replace responsive CSS.date, time, and datetime conditions use the timezone configured in WordPress, not necessarily the visitor’s local timezone.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]