Elementor popup + Contact Form 7: keep the popup open

How to keep a popup open with Contact Form 7 and Elementor

By default, an elementor popup containing a contact form 7 form will close when the form is submitted.

To prevent this, add the following snippet to your theme's functions.php file:

/**
 * Add extra initialisation for Contact 7 Form in Elementor popups.
 **/
function prefix_elementor_contact7_ini() {
    ?>
<script type='text/javascript'>
jQuery( document ).on( 'elementor/popup/show', () => {
for(var i = 0; i < jQuery(".wpcf7-form").length ; i++) {
wpcf7.init(jQuery(".wpcf7-form")[i]);
}
});
</script>
<?php
}
add_action( 'wp_footer',  'prefix_elementor_contact7_ini' );

Have a web project in mind?

Website design, e-commerce or SEO: our web agency in Paris, Besançon and Normandy can help.

Free quote

Related articles