ameeeee
9/26/2019 - 5:57 AM

WP:Contact form 7 いろいろ

<!-- wp外で使う -->

<?php require_once('./wp/wp-load.php'); ?>
<html>
<head>
  <?php wp_head(); ?>
</head>
<body>
  <?php echo do_shortcode( '[contact-form-7 id="XXX" title="問い合わせフォーム"]' ); ?>
</body>

<?php wp_footer(); ?>
</html>
// 送信後にthanksページに遷移

add_action( 'wp_footer', 'add_thanks_page' );
function add_thanks_page() {
echo <<< EOD
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
  location = 'https://google.com/thanks.html'; /* 遷移先のURL */
}, false );
</script>
EOD;
}