カスタム投稿のアーカイブが表示されません
-
カスタム投稿を有効にして、管理画面より同カスタム投稿に2つのカテゴリーを追加したのですが、追加した2つのカテゴリーのアーカイブが表示されません。
親にあたるアーカイブ(archive-result.php)は表示されるのですが、カテゴリーについては表示させてもarchive.phpの内容が表示されてしまいます。
可能であれば追加した2つのカテゴリーもarchive-result.phpのみで表示できればと考えています。
カスタム投稿も2つ(施工実績、お知らせ)設置する予定で、カスタム投稿ごとにアーカイブは設置予定です。
解決方法を教えていただけますでしょうか。●下記記述内容
・function.pnpの記述内容add_action( ‘init’, ‘create_post_type’ );
function create_post_type() {// お知らせ追加(追加1) ——————————
register_post_type(
‘news’, //カスタム投稿タイプ名を指定
array(
‘labels’ => array(
‘name’ => __( ‘お知らせ’ ) ,
‘singular_name’ => __( ‘お知らせ’ )
),
‘public’ => true,
‘has_archive’ => true,
‘menu_position’ => 5,
‘supports’ => array( ‘title’ , ‘editor’ , ‘author’ , ‘thumbnail’/* , ‘excerpt’ , ‘custom-fields’ , ‘comments’*/ )
)
);// 施工実績追加(追加2) ——————————
register_post_type(
‘result’, //カスタム投稿タイプ名を指定
array(
‘labels’ => array(
‘name’ => __( ‘施工実績’ ) ,
‘singular_name’ => __( ‘施工実績’ )
),
‘public’ => true,
‘has_archive’ => true,
‘menu_position’ => 5,
‘supports’ => array( ‘title’ , ‘editor’ , ‘author’ , ‘thumbnail’/* , ‘excerpt’ , ‘custom-fields’ , ‘comments’*/ )
)
);register_taxonomy(
‘news_cat’,
‘news’,
array(
‘label’ => ‘お知らせカテゴリー’,
‘labels’ => array(
‘all_items’ => ‘カテゴリ一覧’,
‘add_new_item’ => ‘新規カテゴリーを追加’
),
‘hierarchical’ => true,
‘rewrite’ => array(
//’single’ => ‘menu/category’,
‘with_front’ => false
),
‘public’ => true,
‘show_ui’ => true
)
);register_taxonomy(
‘news_tag’,
‘news’,
array(
‘hierarchical’ => false,
‘update_count_callback’ => ‘_update_post_term_count’,
‘label’ => ‘タグ’,
‘singular_label’ => ‘タグ’,
‘public’ => true,
‘show_ui’ => true
)
);register_taxonomy(
‘result_cat’,
‘result’,
array(
‘label’ => ‘施工実績カテゴリー’,
‘labels’ => array(
‘all_items’ => ‘カテゴリ一覧’,
‘add_new_item’ => ‘新規カテゴリーを追加’,
),
‘hierarchical’ => true,
‘rewrite’ => array(
//’single’ => ‘menu/category’,
‘with_front’ => false
),
‘public’ => true,
‘show_ui’ => true
)
);register_taxonomy(
‘result_tag’,
‘result’,
array(
‘hierarchical’ => false,
‘update_count_callback’ => ‘_update_post_term_count’,
‘label’ => ‘タグ’,
‘singular_label’ => ‘タグ’,
‘public’ => true,
‘show_ui’ => true
)
);
}
- トピック「カスタム投稿のアーカイブが表示されません」には新たに返信することはできません。