---
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-28
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 only when the values are identical.
- Keep HTML stays on by default, but turning it off prevents private content like 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 widget is a part of The Plus Addons for Elementor Pro, make sure it’s 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 I can set a display condition based on a shortcode in Elementor?**
A: The key requirement is The Plus Addons for Elementor Pro, because Display Condition is part of the Pro version and is not in the free plugin. It also has to be switched on under The Plus Addons &gt; Extensions before it appears in Elementor. That matters because the editor still shows everything, so the real test happens on the published page, ideally in a private window if login status affects the rule.

**Q: How does Elementor compare a shortcode output when using Display Condition?**
A: The match is exact, character for character. The Plus Addons for Elementor, The Plus Addons, Plus Addons for Elementor, POSIMYTH compares what the shortcode returns with the Enter Value field, so hello matches hello but not Hello, hello with a trailing space, or hello. That makes short, predictable outputs like yes or no easier to work with than long formatted strings.

**Q: Why is my shortcode-based display condition not showing the element?**
A: The most common failure is a mismatch between the shortcode output and Enter Value. Case differences, extra spaces, or HTML added by the shortcode can break the match even when the text looks close. A practical way to debug it is to output the shortcode on a test page and inspect exactly what it returns before using that value in Display Condition.

**Q: Should I keep HTML on or off for private content in Display Condition?**
A: Keep HTML controls whether a hidden element is still sent to the browser. When it is on, the content can still exist in page source and be hidden with CSS. For private content like members-only details or prices for logged-in customers, turning it off is safer because the element is not sent at all. That distinction matters more than most people expect.

**Q: Can I use shortcode-based display conditions for membership or personalization blocks?**
A: That use case fits the feature well. The page calls out membership sites showing exclusive content blocks only to logged-in users with a specific shortcode condition, plus developer-built sites where shortcode output drives A/B testing or personalisation. The important part is that your shortcode returns a predictable value that Display Condition can compare exactly.

**Q: What are the main limitations of shortcode display conditions in The Plus Addons for Elementor?**
A: The rule only supports exact match logic. There is no contains, greater than, or less than behavior, and the shortcode runs on every page view so it needs to stay fast. It is also Pro only. In practice, that means this feature works best when your shortcode returns a small stable token and not dynamic formatted content.
