Here are two possible methods you can use to achieve this:
In certain cases, you may find it necessary or preferable to create your dynamic content using an If-So trigger instead of directly setting the condition at the element level. This approach can be beneficial for the following reasons:
When you set up a trigger, If-So first checks the condition of the first content version, if it is met, the version is displayed, if not, it checks the condition of the next content version.
You can create as many versions as you want.
One limitation of using triggers compared to conditional Elementor elements is that you cannot directly create your content using the Elementor editor within the trigger.
For simple text, images, or titles, you can create them directly inside the trigger editor (WYSIWYG editor). The content will automatically adopt the styling of the surrounding element on your page.
If you need or prefer to create your content using the Elementor builder, you can simply create it on your page, save it as an Elementor template, and then apply the template to the trigger using the template’s shortcode.
*The same method works if you want to apply the template to the default content field of another element.
Elementor Pro users: On your WordPress Dashboard, navigate to “Templates” and select “Saved Templates”, then Locate the desired template and copy its shortcode.
Free (Elementor) version users: Search for a free third-party plugin, such as Piotnet, that offers similar functionality.
Yes, it does.
Yes, it does. All the functionality and conditions included in the free version will also work with the Elementor integration (click here for a list of the free vs. pro features).
Some Elementor Elements (basically, those using javascript) might not work as expected while If-So’s Page Caching Compatibility option is enabled. The elements are applied as part of an Elementor Template embedded inside If-So using the template’s shortcode.
Luckily, the fix is simpler than describing the problem 🙂
Simply, paste the code below at the end of your functions.php file.
wp_register_script( 'ifso-dummy-enqueue-to-attach-to', '',); wp_enqueue_script( 'ifso-dummy-enqueue-to-attach-to' ); wp_add_inline_script( 'ifso-dummy-enqueue-to-attach-to', " document.addEventListener('ifso_ajax_triggers_loaded',function(){ elementorFrontend.init(); });");
If you are experiencing content duplication at the bottom of the page:
The Elementor button element does not automatically render shortcodes in the “text” field.
If you wish to include an If-So shortcode within an Elementor button field to display dynamic text on the button, you can add the following code snippet to the end of your functions.php file.
//Elementor button - render shortcode in URL
add_filter('elementor/widget/before_render_content',function($el){
if($el->get_name()==='button'){
$link_setting = $el->get_settings('link');
if(!empty($link_setting)){
$link_setting['url'] = do_shortcode($link_setting['url']);
}
$el->set_settings('link',$link_setting);
}
});
To prevent Elementor from escaping the output and hindering our triggers from rendering correctly in Ajax mode, you can add the following code to the website’s functions.php file:
add_filter( ‘elementor_pro/dynamic_tags/shortcode/should_escape’, ‘__return_false’ );
It’s important to note that Elementor intentionally restricts content rendering using Ajax with a dynamic shortcode for security reasons. Changing this setting doesn’t imply that your site becomes vulnerable to attacks by hackers who are not logged in.
If your conditional Elementor video element isn’t loading with Ajax enabled in If-So, add this code snippet to the end of your theme’s functions.php file:
add_action('wp_enqueue_scripts',function(){ if(!function_exists('wp_add_inline_script')) return; wp_add_inline_script( 'if-so', " document.addEventListener('ifso_ajax_triggers_loaded',function(){ if(document.querySelectorAll('.elementor-video').length<=0) return; var initFrontendIfPossible = function(){if(typeof(YT)!=='undefined'){elementorFrontend.init();return true;}return false;} initFrontendIfPossible(); var interval = setInterval(function(){ if(initFrontendIfPossible()) clearInterval(interval); },1000) });"); },100);