Wordpress电子邮件发布内容

时间:2014-06-24 11:24:53

标签: wordpress email

我在functions.php中有这个功能,可以在发布新帖子时发送电子邮件。

如何将帖子内容添加为电子邮件中的邮件。

function authorNotification($post_id) {

   $to = 'email@hotmail.co.uk';

   $subject = 'New Post';

   $message = $post_id->post_content;

   $headers = 'Content-type: text/html';

   wp_mail($to, $subject, $message, $headers);
}
add_action('publish_post', 'authorNotification');

1 个答案:

答案 0 :(得分:1)

试试这个: -

function authorNotification($post_id) {

   $to = 'email@hotmail.co.uk';

   $subject = 'New Post';

   $post_obj = get_post($post_id); 
   $postcontent = $post_obj->post_content;

   $message = $postcontent;

   $headers = 'Content-type: text/html';

   wp_mail($to, $subject, $message, $headers);
}
add_action('publish_post', 'authorNotification');