对您的问题的最简单答案是将标签放在您的<?php>
标签周围,如下所示:$google_map
<a>
<a target="_blank" href="<?php echo $google_map; ?>">See map</span></a>
我假设您已经在 PHP 文档的某处定义了该变量,但您不应该像这样将硬编码变量放入 WordPress 模板中。如果它是一个自定义字段并且这个 PHP 变量需要在 WordPress 循环中打印,那么解决方案看起来更像这样:
<a target="_blank" href="<?php the_field('google_map_variable_input'); ?>">See map</span></a>
如果您自己生成 HTML 电子邮件,则需要定义比此处列出的更多的参数。这是一个改编自网络教程 HTML 电子邮件的基本示例,它应该让您大致了解如何在 PHP 中格式化 HTML 电子邮件:
<?php
// Setup sending address parameters for eventual php mail() call
$to = 'someone@example.com';
$subject = 'Email Update About XYZ';
$from = 'person@example.com';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Create email headers
$headers .= 'From: '.$user_email."\r\n".
'Reply-To: '.$user_email."\r\n" .
'X-Mailer: PHP/' . phpversion();
// Create email body
// Again, assumes $google_map is defined somewhere else
$message = '<html><body>';
$message .= '<a target="_blank" href="';
$message .= $google_map;
$message .= '" style="color:#267ec8; font-size:14px; line-height:22px; font-weight:normal" color="#267ec8"><span style="color:#267ec8; font-size:14px; line-height:22px; font-weight:normal">See map</span></a>';
$message .= '</body></html>';
// Send email
if(mail($to, $subject, $message, $headers)){
echo 'Your mail has been sent successfully.';
} else{
echo 'Unable to send email. Please try again.';
}
?>