Если вы используете контактную форму 7 в конструкторе всплывающих окон Elementor Pro, вы можете столкнуться с ошибкой, когда при нажатии кнопки «Отправить» обновляется вся страница. Он не показывает сообщение об ошибке или успехе
Чтобы исправить это, требуется внести некоторые изменения в код вашей темы WordPress, чтобы он работал должным образом, не обновляя всю страницу.
Одно из решений (проверено лично на моем сайте) — вставить приведенный ниже код в файл functions.php (расположенный в / wp-content / themes / [your-theme] /).
/**
* Add extra initialisation for Contact 7 Form in Elementor popups.
**/
function prefix_elementor_contact7_ini() {
?>
<script type='text/javascript'>
/** Document ready. We are waiting for the full page load. */
jQuery( document ).ready( function() {
/** Click on link or button that opens the popup. It contain "#elementor-action" in href. */
jQuery( document ).on( 'click', "a[href='#elementor-action']", function() {
/** Let's give the elementor some time to animate popup. */
setTimeout( function() {
/** Find all Contact 7 forms inside elementor popup. */
jQuery( '.elementor-popup-modal form.wpcf7-form:not(.elementor)' ).each( function (index) {
wpcf7.initForm( jQuery( this) ); // Extra initialisation for contact 7 form.
jQuery( this ).addClass( 'elementor' ); // Mark our form with class '.elementor' so as not to do the same thing.
} );
}, 800 ); // END Timeout.
} ); // END link click.
} ); // END Document ready.
</script>
<?php
}
add_action( 'wp_footer', 'prefix_elementor_contact7_ini' );Приведенный выше код был добавлен в Github @drinkmaker, и вы можете узнать больше по ссылке: https://github.com/elementor/elementor/issues/7798
Если вышеперечисленное не работает, вы также можете попробовать другие решения, опубликованные внутри.
Источник записи: https://yugenelee.com