●スラッグ
「レッスン」 → lesson
「ギター」 → lesson_guitar
「ベース」 → lesson_bass
「ドラム」 → lesson_drum
functions.php
//カスタム投稿タイプ追加
register_post_type(
'lesson', //カスタム投稿のスラッグ
array(
'label' => 'レッスン検索', //管理画面に表示される名前
'hierarchical' => true,
'has_archive' => true,
'public' => true,
'menu_position' => 5,
'supports' => array('title','editor'),
'exclude_from_search' => false,
));
//カスタムタクソノミー追加
add_action( 'init', 'add_custom_taxonomy_event', 0 );
function add_custom_taxonomy_event() {
register_taxonomy(
'lesson_guitar', //カスタムタクソノミーのスラッグ
'lesson', //上のカスタム投稿タイプ追加で指定したスラッグ
array(
'hierarchical' => true,
'update_count_callback' => '_update_post_term_count',
'label' => 'ギター', //管理画面に表示される名前
'public' => true,
'show_ui' => true,
));
}
add_action( 'init', 'add_custom_taxonomy_event02', 0 );
function add_custom_taxonomy_event02() {
register_taxonomy(
'lesson_bass', //カスタムタクソノミーのスラッグ
'lesson', //上のカスタム投稿タイプ追加で指定したスラッグ
array(
'hierarchical' => true,
'update_count_callback' => '_update_post_term_count',
'label' => 'ベース', //管理画面に表示される名前
'public' => true,
'show_ui' => true,
));
}
add_action( 'init', 'add_custom_taxonomy_event03', 0 );
function add_custom_taxonomy_event03() {
register_taxonomy(
'lesson_drum', //カスタムタクソノミーのスラッグ
'lesson', //上のカスタム投稿タイプ追加で指定したスラッグ
array(
'hierarchical' => true,
'update_count_callback' => '_update_post_term_count',
'label' => 'ドラム', //管理画面に表示される名前
'public' => true,
'show_ui' => true,
));
}