register_post_type()
関数に登録されたカスタム投稿タイプを追加または編集したときに表示される通知メッセージ(「投稿された投稿」または「更新された投稿」)をカスタマイズする方法は?
post_updated_messages
フィルタを使うことができます。
add_filter( 'post_updated_messages', 'rw_post_updated_messages' );
function rw_post_updated_messages( $messages ) {
$post = get_post();
$post_type = get_post_type( $post );
$post_type_object = get_post_type_object( $post_type );
$messages['my-post-type'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'My Post Type updated.' ),
2 => __( 'Custom field updated.' ),
3 => __( 'Custom field deleted.'),
4 => __( 'My Post Type updated.' ),
/* translators: %s: date and time of the revision */
5 => isset( $_GET['revision'] ) ? sprintf( __( 'My Post Type restored to revision from %s' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __( 'My Post Type published.' ),
7 => __( 'My Post Type saved.' ),
8 => __( 'My Post Type submitted.' ),
9 => sprintf(
__( 'My Post Type scheduled for: <strong>%1$s</strong>.' ),
// translators: Publish box date format, see http://php.net/date
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) )
),
10 => __( 'My Post Type draft updated.' )
);
//you can also access items this way
// $messages['post'][1] = "I just totally changed the Updated messages for standards posts";
//return the new messaging
return $messages;
}