The Conditional Content shortcode for WordPress can be used to display programmatic content to users based on various set conditions. With the use of different comparison operators, the Conditional Content is a powerful option to generating and displaying combination of predefined text snippets based on true or false statements. Check below for example implementations and shortcode documentation:
Conditional Content Examples
Content shown if expression is TRUE
Conditional Content Shortcodes
[x3m-if condition="number(60) greater number(50)"]
Content shown if expression is TRUE
[x3m-else]
Content shown if expression is FALSE
[/x3m-if]
The shortcode can be used to mix and display custom content to users based on the the conditional value of a single or multiple expressions. With a wide range of conditional operators to use and numerous value sources (other value shortcodes, Woocommerce value etc), the Conditional Content shortcode can provide a unique mix of content based on a page/product linked values.
Conditional Content Documentation
Here are the shortcode option settings available for Conditional Content.
Each x3m-if accepts one condition or multiple conditions separated by operators like AND, OR or NOT. Therefore a condition can look like this condition=”number(60) greater number(50)” but also like this condition=”number(60) greater number(50)” AND condition=”number(10) greater number(20)”.
Operators Between Conditions
- AND – this is used to set 2 or more conditions; each of them needs to be true for the overall x3m-if to return true.
- OR – this is used to set 2 or more conditions; only one of them needs to be true for the overall x3m-if to return true.
- NOT – this is used to set 2 or more conditions; first condition must return true while at the same time second condition also returns true by exclusion for the x3m-if to return true.
USE EXAMPLES
🎯 Operators Inside Conditions
Inside each condition we have 2 values to compare with an operator which is used to make the comparison. The Conditional Content shortcode makes use of several data specific operators, which must be used for comparing specific value. Below are a list of the operators available for specific data cases:
Numerical-Specific Operators
Numerical operators are used to compare two numerical values (ex: value of number 1 versus value of number 2).
| Numerical Condition |
Details |
| greater or greater-than |
used to compare 2 values; if value 1 is greater than value 2, the condition is true. Similar to math condition “>”.
|
| less or less-than |
used to compare 2 values; if value 1 is less than value 2, the condition is true. Similar to math condition “<".
|
| equal or equals |
used to compare 2 values; if value 1 equals value 2, the condition is true. Similar to math condition “=”.
|
| not-equal or neq |
used to compare 2 values; if value 1 is not equal/different from value 2, the condition is true. Similar to math condition “<>“.
|
| greater-or-equal or min |
used to compare 2 values; if value 1 is greater or equal to value 1, the condition is true. Similar to math condition “>=”.
|
| less-or-equal or max |
used to compare 2 values; if value 1 is less or equal to value 2, the condition is true. Similar to math condition “<=".
|
USE EXAMPLES
String-Specific Operators
String operators are used to compare two string values (ex: expression 1 versus expression 2).
| String Condition |
Details |
| contains |
used to check if value 1 contains the string from value 2 (compare substring or array contains).
|
| not-contains |
used to check if value 1 does not contains the string from value 2 (compare substring or array contains).
|
| in-list |
used to check if value 1 exists in list from value 2. If it exists in list, then condition returns true.
|
| not-in-list |
used to check if value 1 does not exist in list from value 2. If it does not exist in list, then condition returns true.
|
| between |
used to check if value 1 is within range of value 2.
|
| not-between |
used to check if value 1 is not within range of value 2.
|
| starts-with |
used to check if value 1 starts with value 2 (checks string prefix).
|
| ends-with |
used to check if value 1 ends with value 2 (checks string suffix).
|
| regex |
used to check if value 1 matches value 2 (Regex match).
|
| is-empty |
used to check if value 1 is empty string, null or empty array (no need for value 2 to be set).
|
| not-empty |
used to check if value 1 has a value (no need for value 2 to be set).
|
USE EXAMPLES
Date-Specific Operators
Date operators are used to compare two date values in time (ex: date 1 versus date 2).
| Date Condition |
Details |
| before |
used to check if date value 1 is before date value 2 (compares 2 dates).
|
| after |
used to check if date value 1 is after date value 2 (compares 2 dates).
|
| today |
used to check if date value 1 is same with today date.
|
| now |
used to check if date value 1 is current moment.
|
| weekday |
used to check if date value 1 matches a weekday.
|
USE EXAMPLES
🔧 Data Type Casting
Now, since we enumerated the conditional operators which can be used, we also have a range of data type casting recommended for use. Without their use, a numerical value may be seen rather as a string and the conditional value may return false results.
| Type Casting |
Details |
| number(..) |
used to set numeric cast (int + float unified). Use example as number(8).
|
| int(..) |
used to set integer cast (int + float unified). Use example as int(8.4) will see the value as 8.
|
| float(..) |
used to set float cast (int + float unified). Use example as float(8.4) will see the value as 8.4.
|
| string(..) |
used to force string comparison. Ideal for content/text like values. Use example as string(text here)
|
| bool(..) |
used for boolean normalization.
|
| count(..) |
used to count elements in array/string.
|
| length(..) |
used to calculate string length. Use example length(text) will return 4.
|
| percent(..) |
used to parse percentage values. Use example percent(10) or percent(10%) are same values.
|
USE EXAMPLES
📄 Value Sources
Inside the data type casting (..) we need to set real values/text to evaluate. Data sources may also include dynamic data from the WordPress installation or data shortcodes from other plugins.
Post / Content Sources
| Post / Content Source |
Details |
| post.id |
returns Current Post ID (numeric value, e.g., 123, 456)
|
| post.type |
returns Post type slug (post, page, product, attachment, revision, nav_menu_item, custom_css, customize_changeset, or any custom post type slug)
|
| post.status |
returns Post type slug (publish, pending, draft, auto-draft, future, private, inherit, trash)
|
| post.title |
returns Post title (string, use contains/starts-with/ends-with for partial matching)
|
| post.slug |
returns Post slug (lowercase string with hyphens, e.g., my-post-title)
|
| post.content |
returns Raw post content (full HTML content, use contains for keyword matching)
|
| post.excerpt |
returns Post excerpt (string, may be empty if not set)
|
| post.author.id |
returns Author user ID (numeric value)
|
| post.author.role |
returns Author primary role (slug) (administrator, editor, author, contributor, subscriber, or custom roles)
|
| post.date |
returns Publish date in format “Y-m-d H:i:s” (e.g., 2026-02-21 14:30:00)
|
| post.modified |
returns Last modified date in Y-m-d H:i:s format
|
| post.meta:key |
returns Post meta value – replace “key” with meta key name (returns stored value, ACF compatible)
|
| post.tax:taxonomy |
returns Assigned taxonomy terms – replace “taxonomy” with taxonomy name like category, post_tag, product_cat (returns comma-separated term names)
|
User / Visitor Sources
| User / Visitor Source |
Details |
| user.id |
returns Current user ID (numeric value, 0 if not logged in)
|
| user.role |
returns Primary user role slug (administrator, editor, author, contributor, subscriber, customer, shop_manager, or custom roles)
|
| user.roles |
returns all assigned roles as comma-separated string (e.g., “administrator, editor”)
|
| user.capability |
Capability check – returns true/false (common caps: edit_posts, publish_posts, edit_pages, manage_options, upload_files, edit_users, delete_posts, moderate_comments, manage_categories, edit_others_posts, read_private_posts)
|
| user.logged_in |
returns Login state (true or false)
|
| user.meta:key |
returns User meta value – replace “key” with meta key name (returns stored value)
|
| user.registered |
returns Registration date in Y-m-d H:i:s format
|
Request / Session Sources
| Request / Session Source |
Details |
| request.get:key |
returns URL query parameter – replace “key” with parameter name (e.g., request.get:utm_source returns value from ?utm_source=value)
|
| request.post:key |
returns POST parameter – replace “key” with field name (returns submitted form value)
|
| request.method |
returns HTTP Request method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
|
| cookie:name |
returns Cookie value – replace “name” with cookie name (returns stored cookie value or empty)
|
| referer |
returns HTTP referer URL (full URL of previous page, empty if direct visit or blocked by browser)
|
Site / Environment Sources
| Site / Environment Source |
Details |
| option:key |
returns WordPress option value – replace “key” with option name (common: blogname, blogdescription, admin_email, date_format, time_format, timezone_string, posts_per_page, users_can_register, woocommerce_currency)
|
| site.locale |
returns Site language code (en_US, en_GB, de_DE, fr_FR, es_ES, it_IT, pt_BR, ru_RU, zh_CN, ja, ko_KR, ar, etc.)
|
| site.url |
returns Site URL (e.g., https://example.com)
|
| is_multisite |
returns if Multisite enabled (true or false)
|
Query Context Flags
| Query Context Flag |
Details |
| is_home |
returns Is home page (true or false)
|
| is_front_page |
returns Is site front page/homepage (true or false)
|
| is_single |
returns Is single post view – any post type except page/attachment (true or false)
|
| is_page |
returns Is static page (true or false)
|
| is_archive |
returns Is any archive page – category, tag, author, date, custom taxonomy (true or false)
|
| is_search |
returns Is search results page (true or false)
|
| is_404 |
returns Is 404 not found page (true or false)
|
| is_category |
returns Is category archive page (true or false)
|
| is_tag |
returns Is tag archive page (true or false)
|
| is_tax |
returns Is custom taxonomy archive page (true or false)
|
| is_author |
returns Is author archive page (true or false)
|
Date / Time Sources
| Date / Time Source |
Details |
| date.today |
returns Current date in Y-m-d format (e.g., 2026-02-21)
|
| date.now |
returns Current date & time in Y-m-d H:i:s format (e.g., 2026-02-21 14:30:00)
|
| date.weekday |
returns Current weekday in lowercase (monday, tuesday, wednesday, thursday, friday, saturday, sunday)
|
Device / Client Sources
| Device / Client Source |
Details |
| device.type |
returns Device type (mobile, tablet, desktop).
|
| browser.name |
returns Browser name in lowercase (chrome, firefox, safari, edge, unknown)
|
| os.name |
returns Operating system in lowercase (windows, mac, linux, ios, android, unknown)
|
WooCommerce Sources
| WooCommerce Source |
Details |
| wc.product.id |
returns Product ID (numeric value)
|
| wc.product.type |
returns Product type (simple, variable, grouped, external, subscription, variable-subscription)
|
| wc.product.price |
returns Active product price – sale price if on sale, otherwise regular (numeric value)
|
| wc.product.regular_price |
returns Regular price before any sale (numeric value)
|
| wc.product.sale_price |
returns Sale price if set (numeric value, empty if not on sale)
|
| wc.product.on_sale |
returns On sale status (true or false)
|
| wc.product.stock |
returns Stock quantity (numeric value, null if not managed)
|
| wc.product.stock_status |
returns Stock status (instock, outofstock, onbackorder)
|
| wc.product.sku |
returns SKU string (product identifier code)
|
| wc.product.virtual |
returns Virtual product flag (true or false)
|
| wc.product.downloadable |
returns Downloadable product flag (true or false)
|
| wc.product.tax:product_cat |
returns Product categories as comma-separated names
|
| wc.cart.total |
returns Cart total (numeric value in shop currency)
|
| wc.cart.items_count |
returns Number of items in cart (numeric value, 0 if empty)
|
| wc.cart.contains |
returns Checks if cart contains product ID – replace ID with product ID number (true or false)
|
| wc.customer.total_spent |
returns Lifetime spend (numeric value in shop currency)
|
| wc.customer.orders_count |
returns Total completed orders count (numeric value)
|