基本前提:邮件程序允许最终用户键入他们的姓名,他们的电子邮件并向电子邮件收件人发送他们选择的evite(只是图像) . 收件人会收到包含图像和问候消息的电子邮件模板 .

我已经 Build 了电子邮件功能并且它可以工作,只需要弄清楚如何打印从wordpress循环内部的自定义字段吐出的数据 .

这是我为了测试目的而嘲笑的电子邮件的正文:

$body = "
<html>
<head>
<title>new evite!</title>
</head>
<body>
<p>Here is your new evite</p>
<table>
<tr>
<td><img src='".$thePostID."' alt='' /></td>
</tr>
<tr>
<td>Name: $name
Email: $email
Comments: $comments</td> </tr> </table> </body> "

$ thePostID定义:

$thePostID = the_field('evite_large_preview');

the_field函数来自流行的wordpress插件,高级自定义字段 .

the_field( 'evite_large_preview');只会从帖子中回显出图片的网址 .

$ thePostID没有回显任何值,因此当收件人检查他们的电子邮件时,不显示任何图像 .

为什么会发生这种情况?该功能在网站上运行得很好,但没有显示在电子邮件正文中 .

EDIT: I figured it out:

Used get_field instead of the_field for storing 'field' as variable. Placed variable inside of its own wordpress loop solved it.