###前提・実現したいこと
WordPressのカスタム投稿タイプで"taxonomies" => array( "category" )と記述した、あるいはCPTUIの『利用するタクソノミー』で『カテゴリー (WP コア)』を選択した場合の「スラッグごと」の表示の仕方をご教示頂ければ幸いです。
###発生している問題・エラーメッセージ
カスタム投稿タイプ「area」内に置いた情報に対し「東京(tokyo),新宿(shinjyuku)・・・(注)」というスラッグを割り当て、例えば「東京」をクリックすると「/category/tokyo/」の一覧がでるようにしたいのですが、実現しません。
(注:実際の名称とは相違します)
###該当のソースコード
functions.phpに以下のように記述しました。
CPTUIでも同様のことを試しています。
add_action( 'init', 'create_post_type' ); function create_post_type() { $labels = array( "name" => __( 'エリア', '' ), "singular_name" => __( 'エリア', '' ), ); $args = array( "label" => __( 'エリア', '' ), "labels" => $labels, "description" => "", "public" => true, "publicly_queryable" => true, "show_ui" => true, "show_in_rest" => false, "rest_base" => "", "has_archive" => "area", "show_in_menu" => true, "exclude_from_search" => false, "capability_type" => "post", "map_meta_cap" => true, "hierarchical" => true, "rewrite" => array( "slug" => "area", "with_front" => true ), "query_var" => true, "supports" => array( "title", "editor", "thumbnail" ), "taxonomies" => array( "category" ), ); register_post_type( "area", $args );
http://kotori-blog.com/wordpress/posttype_taxonomy/#content04
を参考に archive-area.php を作成しました。
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> <div class="entry"><?php the_content(); ?></div> <?php endwhile; endif; ?>
###試したこと
使用しているテーマはLightningですが、実現出来るなら他のテーマでも構わないと思い、simplicity2やstinger8でもためしましたが上手くいきません。
タクソノミを生成せずに「WPコア」とした場合上手く行かないのでしょうか。
それとも抜本的に何かを勘違いしているのでしょうか。
※テーマは全て子テーマを使用し、Localhost下で検証作業を行っております。
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/04/16 02:32