您可以使用过滤器post_updated_messages
:
//Message handling when updating posts
function set_messages($messages) {
global $post, $post_ID;
$post_type = get_post_type( $post_ID );
$obj = get_post_type_object($post_type);
$singular = $obj->labels->singular_name;
$messages[$post_type] = array(
0 => \'\', // Unused.
1 => sprintf( __($singular.\' uppdaterad. <a href="%s">Visa \'.strtolower($singular).\'</a>\'), esc_url( get_permalink($post_ID) ) ),
2 => __(\'Custom field uppdaterad.\'),
3 => __(\'Custom field borttagen.\'),
4 => __($singular.\' uppdaterad.\'),
5 => isset($_GET[\'revision\']) ? sprintf( __($singular.\' återställd till revision från %s\'), wp_post_revision_title( (int) $_GET[\'revision\'], false ) ) : false,
6 => sprintf( __($singular.\' publicerad. <a href="%s">Visa \'.strtolower($singular).\'</a>\'), esc_url( get_permalink($post_ID) ) ),
7 => __(\'Sida sparad.\'),
8 => sprintf( __($singular.\' skickad. <a target="_blank" href="%s">Förhandsgranska \'.strtolower($singular).\'</a>\'), esc_url( add_query_arg( \'preview\', \'true\', get_permalink($post_ID) ) ) ),
9 => sprintf( __($singular.\' schemalagd för: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Förhandsgranska \'.strtolower($singular).\'</a>\'), date_i18n( __( \'M j, Y @ G:i\' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __($singular.\' utkast uppdaterad. <a target="_blank" href="%s">Förhandsgranska \'.strtolower($singular).\'</a>\'), esc_url( add_query_arg( \'preview\', \'true\', get_permalink($post_ID) ) ) ),
);
//Special conditions, other messages based on which post-type when updating
if ($obj->name == \'product\') {
//Do something
}
return $messages;
}
//Set messages array for posts. Special cases are handled based on post-type
add_filter(\'post_updated_messages\', \'set_messages\');