我想在发布文章后向作者发送电子邮件。
我拥有的代码
add_action( 'publish_post', 'send_notification' );
function send_notification( $post_id ) {
$post = get_post($post_id);
$content = $post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$post_url = get_permalink( $post_id );
$post_title = get_the_title( $post_id );
$author = get_userdata($post->post_author);
$subject = '$post_title';
$message .= "<a href='". $post_url. "'>'".$post_title."'</a>\n\n";
$message .= $content;
wp_mail($author->user_email, $subject, $message );
}
电子邮件通常会发送给作者,但他会阅读帖子内容的源代码。
我应该如何正常地通过电子邮件而不是帖子中的代码来使作者获得该帖子,>
感谢您的帮助!
我想在发布帖子时向作者发送电子邮件。我的代码具有add_action('publish_post','send_notification');函数send_notification($ post_id){$ post = get_post($ ...
默认情况下,wp_mail
函数发送纯文本电子邮件,说明未转换html标记。