ワードプレス初心者です。
子テーマのfunctions.phpに、2種のカスタム投稿を追加(”お知らせ”と”カスタム”という項目で)コードを書き実装できましたが、タクソノミーの方はなぜか”お知らせ”の方にしか追加できずに困っています。
どのようにコードを書けばいいのか、教えていただけたら嬉しいです。
以下これが私が書いた(ググって、コピペしたもの)ものです。よろしくお願いいたします。
//1.子テーマの設定
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
//2.カスタム投稿
function add_custom_post() {
register_post_type(
'infopage',
array(
'label' => 'お知らせ',
'public' => true,
'has_archive' => true,
'menu_position' => 5,
'supports' => array(
'title',
'editor',
'thumbnail',
'revisions',
'excerpt',
'custom-fields',
)
)
);
register_post_type(
'custom',
array(
'label' => 'カスタム',
'public' => true,
'has_archive' => true,
'menu_position' => 5,
'supports' => array(
'title',
'editor',
'thumbnail',
'revisions',
'excerpt',
'custom-fields',
)
)
);
}
add_action('init', 'add_custom_post');
/////////////////////////
function add_taxonomy() {
//お知らせカテゴリ
register_taxonomy(
'info-cat',
'infopage',
array(
'label' => 'お知らせカテゴリ',
'singular_label' => 'お知らせカテゴリ',
'labels' => array(
'all_items' => 'お知らせカテゴリ一覧',
'add_new_item' => 'お知らせカテゴリを追加'
),
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'hierarchical' => true
)
);
//お知らせタグ
register_taxonomy(
'info-tag',
'infopage',
array(
'label' => 'お知らせのタグ',
'singular_label' => 'お知らせのタグ',
'labels' => array(
'add_new_item' => 'お知らせのタグを追加'
),
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'hierarchical' => false
)
);
}
add_action( 'init', 'add_taxonomy' );
No.1ベストアンサー
- 回答日時:
なにか他に書かれたコードはあるのでしょうか。
みたかぎり、「お知らせ」の分しかコードが書かれていないようです。同じ「お知らせカテゴリ」「お知らせタグ」を「カスタム」にもつけたいなら、
//お知らせカテゴリ
register_taxonomy(
'info-cat',
array( 'infopage','custom'), //ここを変更
//お知らせタグ
register_taxonomy(
'info-tag',
array( 'infopage','custom'), //同じようにここを変更
別のカテゴリ、タグをつけたいなら、今書かれているコードをつけたいカテゴリ、タグで「カスタム」用に作って付け足してください。
例えば、
//カスタムカテゴリ
register_taxonomy(
'custom-cat', //タクソノミーのスラッグ
'custom', //つけたいポストタイプ
array(
'label' => 'カスタムカテゴリ',
'singular_label' => 'カスタムカテゴリ',
'labels' => array(
'all_items' => 'カスタムカテゴリ一覧',
'add_new_item' => 'カスタムカテゴリを追加'
),
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'hierarchical' => true
)
);
参考まで。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・人生のプチ美学を教えてください!!
- ・10秒目をつむったら…
- ・あなたの習慣について教えてください!!
- ・牛、豚、鶏、どれか一つ食べられなくなるとしたら?
- ・【大喜利】【投稿~9/18】 おとぎ話『桃太郎』の知られざるエピソード
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
外国人のコメント欄でよく、コ...
-
ワードプレスCocoonで作ったペ...
-
サーバーについて
-
ホームページ制作とコーティング
-
1つのサーバー契約で複数のドメ...
-
ワードプレスのプラグイン
-
Adobe Express(アドビエクスプ...
-
ワードプレステーマkatawaraのCSS
-
ワードプレスのテーマ:katawara
-
ホームページやブログに関しま...
-
ワードプレスに詳しい方に質問...
-
「ページにリダイレクトがあり...
-
HPを作りたいと考えているので...
-
ワードプレスでデータの移動
-
ワードプレスで新規で新しい記...
-
WP ショートコードの編集?
-
WPにログインした状態で、自分...
-
ワードプレスにユーチューブの...
-
グーグルサーチコンソール。サ...
-
ワードプレスで投稿(ブログ)...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
URLが青くならない
-
リンク先のURLを別の文字にする...
-
ニコニコ動画のタグロックについて
-
Yhoo!ブログで・・・・・・
-
ライブドアブログがタグ付けで...
-
keywords,discriptionタグについて
-
SEO(検索エンジン最適化)について
-
画像ポップアップ(Lity)の使...
-
ホームページにPDFファイルをリ...
-
メール文章に予め定型文を入れ...
-
有料版忍者ツールアクセス解析...
-
楽天ブログにてグーグルマップ...
-
ニコ動のタグ荒らしについて
-
ブログの画像をアマゾンのブッ...
-
Wordで作成した文章をコピーし...
-
YouTubeのリンクの方法
-
バリューコマースのバナー広告...
-
SEOにおける<h1>タグについて
-
アクセスランキングを入れたら...
-
エキサイトブログで、画像の横...
おすすめ情報