カスタム投稿ページのカテゴリーとURL
-
はじめて投稿致します。初心者ですが、どうぞよろしくお願いします。
カテゴリーのslugはfashionで設定しているのですが、実際の記事ページのURLを見てみるとカスタム投稿時に追加した際のspecialというのがURLに表示されており、困っております。また、記事ページで the_category();でもfashionというカテゴリーが表示させれません。
パーマリンクは/%category%/%postname%/こちらで設定しています。
カスタム投稿を追加したコードは下記になります。
カスタム投稿ページのURLをspecialではなく、fashionやその他のカテゴリーに変えるにはどうしたらよいでしょうか。宜しくお願い致します。
add_action( 'init', 'register_cpt_special' ); function register_cpt_special() { $labels = array( 'name' => _x( '特集', 'special' ), 'singular_name' => _x( '特集', 'special' ), 'add_new' => _x( '新規追加', 'special' ), 'add_new_item' => _x( '新しい特集を追加', 'special' ), 'edit_item' => _x( '特集を編集', 'special' ), 'new_item' => _x( '新しい特集', 'special' ), 'view_item' => _x( '特集を見る', 'special' ), 'search_items' => _x( '特集検索', 'special' ), 'not_found' => _x( '特集が見つかりません', 'special' ), 'not_found_in_trash' => _x( 'ゴミ箱に特集はありません', 'special' ), 'parent_item_colon' => _x( '親特集:', 'special' ), 'menu_name' => _x( '特集', 'special' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, 'description' => '特集など', 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields' ), 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => true, 'capability_type' => 'post' ); register_post_type( 'special', $args ); } // 管理画面に特集記事のアイコンを追加 function add_menu_icons_styles(){ echo '<style> #adminmenu #menu-posts-special div.wp-menu-image:before { content: "\f307"; } </style>'; } add_action( 'admin_head', 'add_menu_icons_styles' ); //カテゴリーとタクソノミーをカスタム投稿に追加 add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'special', /* post-type */ array( 'labels' => array( 'name' => __( '特集' ), 'singular_name' => __( '特集' ) ), 'public' => true, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields' ,'comments' ), 'menu_position' =>5, 'has_archive' => true ) ); //カスタムタクソノミー、カテゴリタイプ register_taxonomy( 'special-cat', 'special', array( 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => '特集のカテゴリー', 'singular_label' => '特集のカテゴリー', 'public' => true, 'show_ui' => true ) ); //カスタムタクソノミー、タグタイプ register_taxonomy( 'special-tag', 'special', array( 'hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => '特集のタグ', 'singular_label' => '特集のタグ', 'public' => true, 'show_ui' => true ) ); }
8件の返信を表示中 - 1 - 8件目 (全8件中)
8件の返信を表示中 - 1 - 8件目 (全8件中)
- トピック「カスタム投稿ページのカテゴリーとURL」には新たに返信することはできません。