我正在尝试用主题(帖子标题)和内容来丰富此通知,而不是它的当前视图和编辑链接,有人能帮忙吗?
<?php
function __notify_admin_on_publish( $new_status, $old_status, $ticket )
{
if ( $new_status != \'publish\' || $old_status == \'publish\' )
return;
$message = \'View it: \' . get_permalink( $ticket->ID ) . "\\nEdit it: " . get_edit_post_link( $ticket->ID );
if ( $post_type = get_post_type_object( $ticket->post_type ) )
wp_mail( get_option( \'admin_email\' ), \'New \' . $post_type->labels->singular_name, $message );
}
add_action( \'transition_post_status\', \'__notify_admin_on_publish\', 10, 3 );
?>
最合适的回答,由SO网友:s_ha_dum 整理而成
$ticket
是一个WP_Post
对象它应该包含您需要的所有信息。只需将该信息添加到$message
字符串创建所需的任何内容。裸体示例:
$message = \'You are viewing \'.$ticket->post_title;
$message .= \'Post Content: \'.$ticket->post_content;
$message .= \'View it: \' . get_permalink( $ticket->ID ) . "\\nEdit it: " . get_edit_post_link( $ticket->ID );
如果这不是你想要的,我肯定我不理解这个问题。