有一个few plugins that handle email notifications, 但它们似乎都像是(所有)WordPress用户的订阅服务。
发布帖子或页面时通知您:
/**
* Send an email notification to the administrator when a post is published.
*
* @param string $new_status
* @param string $old_status
* @param object $post
*/
function wpse_19040_notify_admin_on_publish( $new_status, $old_status, $post ) {
if ( $new_status !== \'publish\' || $old_status === \'publish\' )
return;
if ( ! $post_type = get_post_type_object( $post->post_type ) )
return;
// Recipient, in this case the administrator email
$emailto = get_option( \'admin_email\' );
// Email subject, "New {post_type_label}"
$subject = \'New \' . $post_type->labels->singular_name;
// Email body
$message = \'View it: \' . get_permalink( $post->ID ) . "\\nEdit it: " . get_edit_post_link( $post->ID );
wp_mail( $emailto, $subject, $message );
}
add_action( \'transition_post_status\', \'wpse_19040_notify_admin_on_publish\', 10, 3 );
你可以把这个放在你的主题里
functions.php
, 或者将其另存为插件(这可能更合适,因为它与“主题”并不完全相关)。