How to Call Wordpress Elementor Popup From Code?

6 minutes read

To call a WordPress Elementor popup from code, you can use the Elementor Pro Popup.


First, you need to find the ID of the popup you want to call. This can be found in the URL when you are editing the popup in Elementor.


Next, you can use jQuery or JavaScript to trigger the popup using its ID. You can use the elementorProFrontend object to interact with the Elementor Pro plugin and call the popup using its ID.


For example, you can use the following code to trigger the popup with ID 123:

1
elementorProFrontend.modules.popup.showPopup( { id: 123 } );


This code will trigger the popup with ID 123 from your code. You can place this code in your theme's JavaScript file or in a custom plugin.


By following these steps, you can call a WordPress Elementor popup from your code.

Best WordPress Hosting Providers in November 2024

1
Vultr

Rating is 5 out of 5

Vultr

  • Ultra-fast Intel Core
  • High Performance and Cheap Cloud Dedicated Servers
  • 1 click install Wordpress
  • Low Price and High Quality
2
Digital Ocean

Rating is 4.9 out of 5

Digital Ocean

  • Active Digital Community
  • Simple Control Panel
  • Starting from 5$ per month


How to conditionally display Elementor popup based on user actions?

To conditionally display an Elementor popup based on user actions, you can use the Trigger Location feature in Elementor. Here's how you can set it up:

  1. Create the popup: First, create the popup you want to display in Elementor by going to Templates > Popups > Add New Popup. Design the popup as you wish using Elementor's drag-and-drop editor.
  2. Set the trigger location: In the popup settings, go to the Conditions tab and scroll down to the Trigger Location section. Here, you can choose the type of trigger you want to use to display the popup based on user actions.
  3. Choose the trigger type: Elementor offers various trigger options such as On Click, On Scroll, After Inactivity, and On Scroll Down, among others. Choose the trigger type that best suits your needs.
  4. Customize trigger settings: Once you've selected the trigger type, you can further customize the trigger settings, such as delay time, scroll distance, and more.
  5. Save and publish: Once you're done setting up the trigger location, save and publish the popup. It will now be displayed conditionally based on the user actions you specified.


By following these steps, you can easily conditionally display an Elementor popup based on user actions on your website.


What is the function to set a delay before calling an Elementor popup?

One possible way to set a delay before calling an Elementor popup is to use JavaScript's setTimeout function. Here is an example function that sets a delay of 2 seconds before calling the Elementor popup:

1
2
3
4
5
function delayedPopup() {
  setTimeout(function() {
    jQuery('#your-popup-id').elementorProPopup('show');
  }, 2000); // 2000 milliseconds = 2 seconds
}


In this example, replace #your-popup-id with the actual ID of your Elementor popup. You can call this delayedPopup function whenever you want to show the popup after a certain delay.


How to trigger Elementor popup on page load using code?

To trigger an Elementor popup on page load using code, you can use the following JavaScript code:

  1. Identify the unique ID of the Elementor popup you want to trigger. You can find this ID by inspecting the Elementor popup element in the browser developer tools.
  2. Use the following JavaScript code to trigger the Elementor popup on page load:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
jQuery(document).ready(function($) {
    // Replace 'YOUR_POPUP_ID_HERE' with the ID of your Elementor popup
    var popupId = 'YOUR_POPUP_ID_HERE';

    elementorFrontend.waypoint(popupId, function() {
        elementorFrontend.showPopup( {
            id: popupId,
        });
    });
});


  1. Add this JavaScript code to your theme's functions.php file or to a custom script file that is loaded on the page where you want the popup to be triggered.
  2. Replace 'YOUR_POPUP_ID_HERE' with the actual ID of your Elementor popup.
  3. Save your changes and reload the page to see the Elementor popup triggered on page load.


How to localize text strings in Elementor popups called from code?

To localize text strings in Elementor popups called from code, you can follow these steps:

  1. Define your text strings in your theme or plugin using the WordPress localization functions like __() or _e(). For example, you can define a text string like this:
1
__('Hello, World!', 'your-text-domain');


  1. Use the Elementor\Controls_Manager::TEXT control type to add a Text field for your text string in your popup widget. Here is an example of how you can add a text field for the localized text string:
1
2
3
4
5
6
7
8
$elementor->add_control(
    'localized_text',
    [
        'label' => __('Localized Text', 'your-text-domain'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'placeholder' => __('Enter your text here', 'your-text-domain'),
    ]
);


  1. Retrieve the localized text string in your popup code and display it where needed. You can use the get_settings() method to retrieve the value of your text field like this:
1
2
3
$settings = $this->get_settings();
$localized_text = $settings['localized_text'];
echo esc_html($localized_text);


  1. Finally, make sure to include the appropriate translation files in your theme or plugin and provide translations for your text strings in different languages.


By following these steps, you can easily localize text strings in Elementor popups called from code and provide a localized experience for your users.

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

Related Posts:

To add a lightbox popup in Elementor, first, open the Elementor editor for the page where you want to add the popup. Then, select the element you want to trigger the popup, such as an image or button. Next, go to the Advanced tab for that element and locate th...
To open an external link in an Elementor popup, you can create a button or text link in your Elementor layout and then apply the popup feature to that element. Inside the popup settings, you can add the external link URL in the "Link" section. This way...
To add a click event to a popup in Elementor, you can follow these steps:After creating your popup in Elementor, go to the section or element within the popup that you want to trigger the click event. Click on the section or element to select it. In the Elemen...