2014-06-24 82 views
0

我有這個函數在functions.php發送新郵件時發送電子郵件。WordPress的電子郵件發佈內容

如何將郵件的內容作爲郵件添加到電子郵件中。

function authorNotification($post_id) { 

    $to = '[email protected]'; 

    $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

試試這個: -

function authorNotification($post_id) { 

    $to = '[email protected]'; 

    $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'); 
+0

你知道,因爲它在郵件應用程序從WordPress的別的東西顯示出來我會如何改變電子郵件標題。 – ttmt

+0

你的意思是wordpress @ ?? – Khushboo

+0

你可以像下面這樣做: - 打開/wp-includes/pluggable.php並找到wordpress @並用任何你喜歡的替換wordpress,其中有兩個。 – Khushboo