Shortcodes Ultimate for WordPress

WordPress Conditional Shortcode

Show the right content to the right visitor. The Conditional shortcode lets you control WordPress content by user, role, device, language, schedule, request, post context or WooCommerce purchase.

  • 14 built-in visitor, schedule and page conditions
  • Invert any condition with the Is not operator
  • Wrap text, HTML or other shortcodes

Target WordPress content without adding conditional PHP to every template

Some messages should appear only to guests. Others belong to members, editors, mobile visitors, customers, a particular language or a limited campaign window. Showing everything to everyone makes pages less relevant and harder to maintain.

The Conditional shortcode keeps the rule next to the content it controls. Select one condition, provide its related value when needed, and wrap the text, HTML or other shortcodes that should appear when the rule matches.

Every visitor sees the same content

Generic pages cannot adapt messages for guests, members, customers, languages or devices.

Small rules turn into custom PHP

Even a simple logged-in check often means editing templates or maintaining a custom snippet.

Campaign changes become manual work

Scheduled notices and targeted offers are easy to forget when they must be switched by hand.

Conditional keeps the rule with the content

Choose a condition, add the relevant value and wrap the content that should appear.

Use conditional content for visitors, campaigns and customers

Build focused experiences without creating a separate page for every audience. These examples use the exact attribute names supported by the Conditional shortcode.

Member-only messages

Show account links, downloads or instructions only to visitors who are signed in.

[su_conditional condition="logged_in"]View your account resources.[/su_conditional]

Guest calls to action

Invite logged-out visitors to register without repeating the same prompt for existing members.

[su_conditional condition="logged_out"]Create a free account to continue.[/su_conditional]

Role-specific instructions

Give editors and administrators a note that remains hidden from other user roles.

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

Scheduled announcements

Keep a launch, maintenance or promotion message visible only during a defined period.

[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]

Device-specific guidance

Show a short instruction when WordPress identifies the current request as mobile or desktop.

[su_conditional condition="device" device="mobile"]Tap the menu icon to browse sections.[/su_conditional]

Customer-only resources

Reveal a download or onboarding link to a logged-in WooCommerce customer who bought a product.

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

Add targeted content with Shortcodes Ultimate

Choose a condition in the shortcode generator, add your content and test the result—no template edit required.

Choose from 14 built-in conditions

The shortcode includes conditions for visitor identity, request context, content context and schedules. It evaluates one selected condition at a time and ignores fields that belong to other conditions.

Visitor and audience conditions

  • Logged in / logged out: Target authenticated visitors or guests without an additional value.
  • User role: Match one or more role slugs, such as administrator, editor or customer.
  • Device: Match mobile or desktop using WordPress server-side device detection.
  • Language: Match a full locale such as en_US or a two-letter language code such as en.
  • Cookie: Check whether a named cookie exists and, optionally, whether its value matches exactly.
  • WooCommerce purchase: Check whether the logged-in customer bought any product in a comma-separated ID list.

Schedule, request and post conditions

  • Date: Use an inclusive start date, end date or both in YYYY-MM-DD format.
  • Time: Use an inclusive HH:MM range; ranges such as 22:00–06:00 can cross midnight.
  • Date and time: Set precise inclusive boundaries in YYYY-MM-DD HH:MM format.
  • URL: Check whether the current request URL contains the text you provide.
  • HTTP referrer: Check whether the optional browser referrer contains a specific value.
  • Post type: Match one or more post type slugs, such as post, page or product.
  • Post category: Match one or more category slugs or numeric category IDs.

Create conditional WordPress content in four steps

Install Shortcodes Ultimate from the WordPress plugin directory or the download page, then insert Conditional from the shortcode generator.

  1. 1

    Choose one condition

    Select the visitor, date, request, post or WooCommerce rule that should control the content.

  2. 2

    Set Is or Is not

    Keep Is for a direct match, or choose Is not to reverse the result.

  3. 3

    Fill in related fields

    Add only the values required by the selected condition; unrelated fields are ignored.

  4. 4

    Add and test the content

    Place text, HTML or other shortcodes inside the wrapper, then test both matching and non-matching visits.

WordPress Conditional shortcode examples

These examples use real [su_conditional] syntax. Replace roles, dates, cookie names, URLs, product IDs and content values with data from your site. See the Conditional shortcode documentation for the complete option reference.

Hide content from administrators

[su_conditional condition="user_role" operator="is_not" role="administrator"]This notice is for non-administrators.[/su_conditional]

Match a language

[su_conditional condition="language" language="en"]Read the English version of this guide.[/su_conditional]

Use an overnight time range

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

Check a cookie value

[su_conditional condition="cookie" cookie_name="plan" cookie_value="pro"]Thanks for being a Pro member.[/su_conditional]

Match the current URL

[su_conditional condition="url" url_contains="utm_source=newsletter"]Welcome, newsletter reader.[/su_conditional]

Match a referring site

[su_conditional condition="referrer" referrer_contains="example.com"]Here is a resource for referred visitors.[/su_conditional]

Show content on selected post types

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

Show content in selected categories

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

Test dynamic conditions with your cache and site settings

The shortcode evaluates conditions on the WordPress server. That makes the following implementation details important when you configure personalized or time-sensitive content.

Full-page caching

A cached page can reuse one visitor’s output for another. Exclude or vary pages that depend on users, devices, cookies or purchases; the shortcode does not change cache settings.

Device detection

The Device condition uses request headers on the server. It does not react to CSS viewport width and can also be affected by a CDN cache.

Referrer availability

Browsers and privacy tools may omit or shorten HTTP referrer data, so it should not be the only control for important content.

Site timezone

Date, Time and Date and time conditions use the timezone configured in WordPress, not necessarily the visitor’s local timezone.

More than a conditional content shortcode

Shortcodes Ultimate combines conditional content with a broad library of reusable WordPress elements. Put a Button, Box or another supported shortcode inside Conditional to create a targeted call to action without rebuilding the component.

Explore related shortcodes such as Button, Box, Posts and Tabs, or browse the complete shortcodes library and documentation hub.

WordPress Conditional shortcode FAQ

What is a WordPress Conditional shortcode?

A WordPress Conditional shortcode shows its enclosed content only when a selected rule matches the current visitor or request. The Conditional shortcode in Shortcodes Ultimate can evaluate users, devices, languages, dates, times, cookies, URLs, referrers, post context and WooCommerce purchases.

Can I show content only to logged-in or logged-out users?

Yes. Choose the logged_in condition for authenticated visitors or logged_out for guests. You can also select user_role when only specific WordPress roles should see the content.

How do I reverse a condition?

Set operator="is_not". The shortcode will display its content when the selected condition does not match.

Which timezone does the Conditional shortcode use?

Date, Time and Date and time conditions use the timezone configured in WordPress under the site settings. Their range boundaries are inclusive.

Does the Device condition respond to browser width?

No. Device detection happens on the server from request headers through WordPress. It does not change when a browser window is resized and should not replace responsive CSS.

Can the Conditional shortcode check WooCommerce purchases?

Yes. The woocommerce_purchase condition accepts one or more product IDs and matches when the logged-in customer has bought any of them. WooCommerce must be active.

Does full-page caching affect conditional content?

It can. Conditions based on users, devices, cookies or purchases may return the wrong output when a cache or CDN serves the same completed page to different visitors. Configure your cache to bypass or vary affected pages.

Can developers add custom conditions?

Yes. Developers can register a condition name with the shortcodes_ultimate_conditional_conditions filter and calculate its result with the shortcodes_ultimate_conditional_result filter.

Show the right WordPress content at the right time

Add visitor, schedule, request, post and purchase rules with the Conditional shortcode.