「Custom Post Type Permalinks」とカスタム投稿のパーマリンクの設定
-
少し変わった要望に対応するため、「Custom Post Type Permalinks」を使って、カスタム投稿にパーマリンクの設定をしています。
実現したいパーマリンクは
home_url/カスタムタイプ名(今回はservice)/カスタム分類名/%postname%.htmlです。プラグインを使ってリンク設定の部分に
%postname%.html
上記だけだときちんと表示されるのですが
/%servicecat%/%postname%.html
にすると404になってしまいます。functions.phpに書いたカスタム投稿の内容は下記になります。
function add_service_type() { $service_type = array( 'label' => 'サービス一覧', 'labels' => array( 'singular_name' => 'ページ一覧', 'add_new_item' => '新規ページ', 'add_new' => '新規ページ', 'view_item' => '投稿を見る', 'not_found' => '投稿が見つかりませんでした', 'not_found_in_trash' => 'ゴミ箱に投稿はありません', 'search_items' => '投稿を検索', 'has_archive' => true, ), 'public' => true, 'hierarchical' => false, 'menu_position' => 4, 'rewrite' => array('slug' => 'service'), 'supports' => array('title','editor','author','thumbnail','custom-fields') ); register_post_type('service_type' , $service_type); flush_rewrite_rules(); register_taxonomy( 'servicecat', 'service_type', array( 'label' => 'カテゴリー', 'hierarchical' => true, ) ); } add_action('init' , 'add_service_type');
何か足りないものがあるのでしょうか?
どうぞ宜しくお願い致します。
2件の返信を表示中 - 1 - 2件目 (全2件中)
2件の返信を表示中 - 1 - 2件目 (全2件中)
- トピック「「Custom Post Type Permalinks」とカスタム投稿のパーマリンクの設定」には新たに返信することはできません。