{"id":120402,"date":"2023-06-23T12:15:57","date_gmt":"2023-06-23T06:45:57","guid":{"rendered":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/?post_type=documents&#038;p=120402"},"modified":"2023-06-26T16:26:03","modified_gmt":"2023-06-26T10:56:03","slug":"set-elementor-display-condition-based-on-shortcode","status":"publish","type":"documents","link":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/docs\/set-elementor-display-condition-based-on-shortcode\/","title":{"rendered":"How to Set Elementor Display Condition Based on Shortcode?"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<p><em>To check the complete feature overview documentation of The Plus Addons for Elementor Display Condition extension, <a href=\"\/docs\/display-conditions-settings-overview\/\" target=\"_blank\" rel=\"noreferrer noopener\">click here<\/a>.<\/em><\/p>\n\n\n\n<p><strong><em>Requirement&nbsp; &#8211; This extension is a part of The Plus Addons for Elementor, make sure it&#8217;s installed &amp; activated to enjoy all its powers.<\/em><\/strong><\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-a89b3969 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-width wp-block-button__width-75 is-style-fill\"><a class=\"wp-block-button__link has-nxt-global-color-8-color has-nxt-global-color-1-background-color has-text-color has-background wp-element-button\" href=\"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/plus-extras\/display-rules?utm_source=tpae&amp;utm_medium=docs&amp;utm_campaign=text\" style=\"border-radius:5px\" target=\"_blank\" rel=\"noreferrer noopener\">LIVE WIDGET LINK<\/a><\/div>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>Note: This option is for advanced users only.<\/em><\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p>First, you have to <a href=\"https:\/\/kinsta.com\/blog\/wordpress-shortcodes\/\" target=\"_blank\" rel=\"noreferrer noopener\">create your shortcode<\/a> in the <em>functions.php<\/em> file of your theme.&nbsp;<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>Note: Any customisation should be done in the child theme.<\/em><\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p>For example, we\u2019ve created this shortcode.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function function_name_unique($atts) {\nreturn 'hello';\n}\nadd_shortcode('my_shortcode', 'function_name_unique');<\/code><\/pre>\n\n\n\n<p>Here our shortcode name is <em>my_shortcode<\/em> and the value is <em>hello<\/em>.<\/p>\n\n\n\n<p>To add display conditions based on shortcode, add any Elementor widget on the page.&nbsp;<\/p>\n\n\n\n<p>1. Go to <strong>Advanced<\/strong> &gt; <strong>Plus Extras : Display Condition<\/strong>.&nbsp;<\/p>\n\n\n\n<p>2. Turn on the <strong>Display Condition<\/strong> toggle.<\/p>\n\n\n\n<p>Now you\u2019ll see an option called <strong>Keep HTML<\/strong>. Enabling this will hide the content in the frontend if the condition is false but it will remain in the HTML (DOM).<\/p>\n\n\n\n<p>3. After selecting the appropriate option from the <strong>Display When<\/strong> dropdown, go to the <strong>Rules<\/strong> section, here you have to set the actual display condition. You can have one or multiple conditions\/rules.<\/p>\n\n\n\n<p>4. Then click on the <strong>Rule<\/strong> tab. Here you\u2019ll find the Shortcode option under the <strong>Shortcode <\/strong>label.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"266\" height=\"1024\" src=\"https:\/\/etemplates.wdesignkit.com\/wp-content\/uploads\/sites\/55\/2023\/06\/display-condition-shortcode-266x1024.gif\" alt=\"display condition shortcode\" class=\"wp-image-120403\" srcset=\"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-content\/uploads\/sites\/55\/2023\/06\/display-condition-shortcode-266x1024.gif 266w, https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-content\/uploads\/sites\/55\/2023\/06\/display-condition-shortcode-78x300.gif 78w\" sizes=\"(max-width: 266px) 100vw, 266px\" \/><\/figure>\n\n\n\n<p>5. Then in the second dropdown, you have two options &#8211;&nbsp;<\/p>\n\n\n\n<p><strong>Is<\/strong> &#8211; This will make the statement true.<\/p>\n\n\n\n<p><strong>Not<\/strong> &#8211; This will make the statement false.<\/p>\n\n\n\n<p>6. Then in the <strong>Enter Shortcode<\/strong> field, you have to add your shortcode, here it will be [my_shortcode].<\/p>\n\n\n\n<p>7. Finally, in the <strong>Enter Value<\/strong> field, you have to add the value, which is <em>hello<\/em> as per our example.<\/p>\n\n\n\n<p>Since the value here and in our shortcode is the same, the content will display here, but if it doesn\u2019t match, then the content will not display.<\/p>\n\n\n\n<p>If the option is set to <strong>Not<\/strong> in the second dropdown, it will reverse the condition.<\/p>\n\n\n\n<p>Also, read <a href=\"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/docs\/set-elementor-display-condition-based-on-woocommerce-product\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Set Elementor Display Condition Based on Woocommerce Product<\/a>.<\/p>\n","protected":false},"author":25,"featured_media":120405,"parent":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","docs":[565,525],"class_list":["post-120402","documents","type-documents","status-publish","format-standard","has-post-thumbnail","hentry","docs-display-conditions","docs-plus-extras"],"acf":[],"_links":{"self":[{"href":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-json\/wp\/v2\/documents\/120402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-json\/wp\/v2\/documents"}],"about":[{"href":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-json\/wp\/v2\/types\/documents"}],"author":[{"embeddable":true,"href":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-json\/wp\/v2\/comments?post=120402"}],"version-history":[{"count":0,"href":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-json\/wp\/v2\/documents\/120402\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-json\/wp\/v2\/media\/120405"}],"wp:attachment":[{"href":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-json\/wp\/v2\/media?parent=120402"}],"wp:term":[{"taxonomy":"docs","embeddable":true,"href":"https:\/\/etemplates.wdesignkit.com\/theplusaddons\/wp-json\/wp\/v2\/docs?post=120402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}