您可以使用此代码在收到以下类型的邮件时自动发送电子邮件one
已发布。这是你的主题functions.php
:
<?php
function post_published_notification( $ID, $post ) {
$type = get_post_type($ID);
if ($type == \'post-type-one\'){
$author = $post->post_author; /* Post author ID. */
$name = get_the_author_meta( \'display_name\', $author );
$email = get_the_author_meta( \'user_email\', $author );
$title = $post->post_title;
$permalink = get_permalink( $ID );
$edit = get_edit_post_link( $ID, \'\' );
$to[] = sprintf( \'%s <%s>\', $name, $email );
$subject = sprintf( \'Published: %s\', $title );
$message = sprintf (\'%s, Your article “%s” has been published.\' . "\\n\\n", $name, $title );
$message .= sprintf( \'View: %s\', $permalink );
$headers[] = \'\';
wp_mail( $to, $subject, $message, $headers );
}
}
add_action( \'publish_post\', \'post_published_notification\', 10, 2 );
?>
您可以阅读和代码,并根据需要修改所需的部件。如果你的问题清楚的话,我可以发布一个更准确的答案。然而,函数本身很有解释性。