我正在嘗試發佈帖子時發送郵件。爲此,我在我的function.php文件中編寫了代碼,郵件正確發送,但不會發送特色圖像。我想顯示附加到該帖子的精選圖片。現在在郵件中不顯示特色圖像,但會顯示特殊圖像的鏈接。如何在wp_mail函數的消息部分顯示圖像?
如何才能完成我的任務,以在郵件中顯示精選圖像?我附上我已經寫在function.php文件中的代碼:
function mysendmail($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$subject = "Post Published: ".$post->post_title."";
$message = "
Hi ".$author->display_name.",
Your post, \"".$post->post_title."\" has just been published.
View post: ".get_permalink($post_id)."
Your Image: ".get_the_post_thumbnail($post->ID)."
Thanks"
;
wp_mail($author->user_email, $subject, $message);
}
add_action('publish_post', 'mysendmail');
剛剛嘗試過將頭添加到wp_mail()函數的代碼,但在郵件輸出中,「your image:」字段顯示空白。 – Abhee