カスタム投稿を2つ追加する場合の書き方です。
/**********************
カスタム投稿タイプ
*********************/
function add_custom_post_type() {
// カスタム投稿1つ目
register_post_type(
'shinchakujoho',
array(
'labels' => array(
'name' => __( '新着情報' ),
'singular_name' => __( '新着情報' )
),
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
// 'excerpt',
'custom-fields',
// 'comments',
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'menu_position' => 5, //「投稿」の下に追加
// //使用するタクソノミーを指定(カテゴリー/category やタグ/post_tag も追加可能)
// 'taxonomies' => array('category')
)
);
// カスタム投稿2つ目
register_post_type(
'Voice',
array(
'labels' => array(
'name' => __( 'お客様の声' ),
'singular_name' => __( 'お客様の声' )
),
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
// 'excerpt',
'custom-fields',
// 'comments',
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'menu_position' => 5, //「投稿」の下に追加
// //使用するタクソノミーを指定(カテゴリー/category やタグ/post_tag も追加可能)
// 'taxonomies' => array('category')
)
);
}
add_action( 'init', 'add_custom_post_type' );