---
title: "How to Set Elementor Display Condition Based on Shortcode?"
url: https://theplusaddons.com/docs/set-elementor-display-condition-based-on-shortcode/
date: 2023-06-23
modified: 2026-09-11
lang: en
author: "Aditya Sharma"
description: "Suppose you are using custom shortcodes to display content on your site. In that case, you can use the Display Condition extension of The Plus Addons for Elementor to add..."
image: https://theplusaddons.com/wp-content/uploads/2023/06/How-to-Set-Elementor-Display-Condition-Based-on-Shortcode_-1024x536.jpg
word_count: 665
---

# How to Set Elementor Display Condition Based on Shortcode?

## 

- The Plus Addons for Elementor Pro includes Display Condition, and it is off by default until The Plus Addons > Extensions turns it on.
- Display Condition appears in the Advanced tab of any Elementor widget, section, or container, not only The Plus Addons widgets.
- Shortcode rules compare the shortcode output with Enter Value character for character, so [my_shortcode] matches hello but not Hello, a trailing space, or hello.
- Keep HTML stays on by default, but turning it off prevents private content such as members-only details or prices for logged-in customers from being sent to the browser.

Suppose you are using custom shortcodes to display content on your site. In that case, you can use the Display Condition extension of The Plus Addons for Elementor to add dynamic visibility conditions on your shortcode content.

*To check the complete feature overview documentation of The Plus Addons for Elementor Display Condition extension, [click here](https://theplusaddons.com/docs/display-conditions-settings-overview/).*

***Requirement  - This extension is a part of The Plus Addons for Elementor, make sure it is installed & activated to enjoy all its powers.***

[LIVE WIDGET LINK](https://theplusaddons.com/elementor-extras/display-conditions/?utm_source=tpae&utm_medium=docs&utm_campaign=text)

## Before You Start

- **Edition:** **Pro** — Display Condition is part of The Plus Addons for Elementor Pro. It does not exist in the free plugin.- **Switch it on.** It is off by default. Go to **The Plus Addons > Extensions** and turn on **Display Condition**.- **Where it appears:** the **Advanced** tab of any Elementor widget, section or container — not only The Plus Addons widgets.

> ***The editor always shows everything.** Conditions are applied only on the published page, so check the result in a private window — logged out if the rule is about login status.*

**Best Used For:**

- Membership sites showing exclusive content blocks only to logged-in users with a specific shortcode condition

- Sites using custom shortcodes to evaluate dynamic data values and conditionally reveal widgets or sections

- Developer-built sites where shortcode output drives visibility logic for A/B testing or personalisation

> *Note: This option is for advanced users only.*

First, you have to [create your shortcode](https://kinsta.com/blog/wordpress-shortcodes/) in the *functions.php* file of your theme. 

> *Note: Any customisation should be done in the child theme.*

For example, we have created this shortcode.

`function function_name_unique() {
return 'hello';
}
add_shortcode('my_shortcode', 'function_name_unique');`

Here our shortcode name is *my_shortcode* and the value is *hello*.

To add display conditions based on shortcode, add any Elementor widget on the page.

1. Go to **Advanced** > **Display Condition**.

2. Turn on the **Display Condition** toggle.

Now you will see **Keep HTML**, which is on by default. While it is on, an element whose conditions are not met is still sent to the browser and hidden with CSS, so its content can be read in the page source. Turn it **off** for anything private — members-only details, prices for logged-in customers — so the element is not sent at all.

3. After selecting the appropriate option from the **Display When** dropdown, go to the **Rules** section to set the actual display condition. You can add one or multiple conditions.

4. Then click on the **Rule** tab. You will find the Shortcode option under the **Shortcode** label.

5. Then in the second dropdown, you have two options - 

**Is** - The rule passes when the condition is met.

**Not** - Reverses the rule: it passes when the condition is not met.

6. In the **Enter Shortcode** field, add your shortcode, for example [my_shortcode].

7. In the **Enter Value** field, add the expected output value, which is *hello* in this example.

Since the value in the field matches the shortcode output, the content will display. If the values do not match, the content will not appear.

If the option is set to **Not** in the second dropdown, the condition is reversed.

Also, read [How to Set Elementor Display Condition Based on WooCommerce Product](https://theplusaddons.com/docs/set-elementor-display-condition-based-on-woocommerce-product/). For URL-based visibility rules, see [How to Set Elementor Display Condition Based on URL String or Parameters](https://theplusaddons.com/docs/set-elementor-display-condition-based-on-url-string-or-parameters/).

## How the Match Works

The rule runs your shortcode and compares what it returns with **Enter Value**, character for character. `hello` matches `hello`, but not `Hello`, `hello ` with a trailing space, or `<p>hello</p>`.

Make the shortcode return a short, predictable word such as `yes` or `no`, and compare against that.

## Limitations

- **Exact match only.** No contains, greater than or less than.- **The shortcode runs on every page view,** so keep it fast.- **Pro only.** Display Condition is not in the free plugin.

## Troubleshooting

### The element never shows

The output differs from Enter Value — often by case, spaces or HTML the shortcode adds. Output the shortcode on a test page to see exactly what it returns.

## Frequently Asked Questions

**Q: What do I need before setting an Elementor display condition based on a shortcode?**
A: The Plus Addons for Elementor, The Plus Addons, Plus Addons for Elementor, POSIMYTH requires the Pro Display Condition extension, and it has to be installed and activated first. The shortcode itself also needs to exist in your theme’s functions.php file, ideally in a child theme so customizations are safer. That matters because the condition compares the shortcode output against a value, so if the shortcode is missing or unstable, the visibility rule cannot behave predictably.

**Q: How does shortcode-based display matching work in Elementor?**
A: The rule runs the shortcode and compares its return value to the Enter Value field character for character. That means hello matches hello, but not Hello, hello with a trailing space, or hello. The practical takeaway is to keep the shortcode output short and predictable, like yes or no, because exact matching is unforgiving and even tiny formatting differences will stop the element from appearing.

**Q: What is the best way to use shortcode display conditions for private content?**
A: Private content should use Keep HTML turned off. When Keep HTML is on, an element that fails its condition is still sent to the browser and only hidden with CSS, which means its content can still be read in page source. Turning it off prevents that leak. That makes it the safer choice for members-only details or prices for logged-in customers inside The Plus Addons for Elementor display conditions.

**Q: Why does my Elementor element never show when I use a shortcode condition?**
A: The most common cause is a mismatch between the shortcode output and Enter Value. Case differences, extra spaces, or HTML added by the shortcode can break the match completely. A good debugging move is to output the shortcode on a test page and inspect exactly what it returns. Since this feature uses exact matching, even a trailing space can stop the condition from passing.

**Q: Can I use shortcode display conditions for membership sites or A/B testing?**
A: That is one of the best fits for this feature. The page calls out membership sites showing exclusive blocks to logged-in users with a specific shortcode condition, plus developer-built sites where shortcode output drives visibility logic for A/B testing or personalisation. It also works well when custom shortcodes evaluate dynamic data values and decide whether widgets or sections should appear.

**Q: What are the limits of Elementor display conditions based on shortcodes?**
A: The rule is exact-match only, so there is no contains logic and no greater-than or less-than comparison. The shortcode also runs on every page view, so it needs to stay fast. This is why The Plus Addons for Elementor positions Display Condition as Pro-only and advanced-user territory: it is powerful, but it depends on clean output and careful performance choices.
