Search code examples
phpwordpresshtml-emailshortcodecontact-form-7

How to include <?php echo $page; ?> inside contact form 7 email in wordpress


How I can include dynamically name of page <?php echo $page; ?> inside contact form 7 in wordpress? I put code into "functions.php" but it is not working.

function cs7() {
  $var='<?php echo $page; ?>';
  $html='<p>'.$var.'</p>';
  return $html;
}

 add_shortcode('cs7', 'cs7');

Solution

  • You can use CF7 special Mail tag to display page or post title from which the form submitted in the mail content.

    [_post_title]
    

    More info here