サポート » 使い方全般 » カスタム投稿タイプの管理画面でカテゴリーを表示させたい

  • 解決済 pitapa

    (@pitapa)


    あちこち調べてみたのですが、初心者なため
    どうして良いかわからず…

    お忙しいところお手数ですが
    どなたかご教授いただけないでしょうか。

    管理画面の、記事が一覧になって見えるところに
    普通の投稿のように「カテゴリー」も表示するには
    どうしたら良いでしょうか。

    本をお手本に、カスタム投稿タイプを作りました。
    functions.php に以下のように書きました。
     

    //果物
    register_post_type(
    'fruit',
    array(
    'label' => '果物',
    'hierarchical' => false,
    'public' => true,
    'query_var' => false,
    'menu_icon' => get_bloginfo('template_url').'/images/fruit_icon-s.gif',
    'supports' => array(
    'title',
    'editor',
    'thumbnail',
    'custom-fields'
    )
    )
    );

    register_taxonomy(
    'fruitcat',
    'fruit',
    array(
    'label' => 'カテゴリー',
    'hierarchical' => true,
    )
    );

    //野菜
    register_post_type(
    'vegetables',
    array(
    'label' => '野菜',
    'hierarchical' => false,
    'public' => true,
    'query_var' => false,
    'menu_icon' => get_bloginfo('template_url').'/images/vegetable_icon-s.gif',
    'supports' => array(
    'title',
    'editor',
    'thumbnail',
    'custom-fields'
    )
    )
    );

    register_taxonomy(
    'vegetablecat',
    'vegetable',
    array(
    'label' => 'カテゴリー',
    'hierarchical' => true,
    )
    );

    //肉類
    register_post_type(
    'meat',
    array(
    'label' => '肉類',
    'hierarchical' => false,
    'public' => true,
    'query_var' => false,
    'menu_icon' => get_bloginfo('template_url').'/images/meat_icon-s.gif',
    'supports' => array(
    'title',
    'editor',
    'thumbnail',
    'custom-fields'
    )
    )
    );

    register_taxonomy(
    'meatcat',
    'meat',
    array(
    'label' => 'カテゴリー',
    'hierarchical' => true,
    )
    );

    //アイコン画像
    add_action('admin_head', 'admin_head_style');
    function admin_head_style() {
    global $post_type;
    if($post_type == 'fruit' || $post_type == 'vegetable' || $post_type == 'meat') {
    ?>
    <style type="text/css">
    #icon-edit {background: url('<?php echo get_bloginfo('template_url'); ?>/images/<?php echo $post_type; ?>_icon.gif');
    background-repeat: no-repeat;}
    </style>
    <?php
    }
    }

    よろしくお願い致します。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • モデレーター jim912

    (@jim912)

    pitapaさん

    拙作の PS Taxonomy Expanderで対応しています。

    トピック投稿者 pitapa

    (@pitapa)

    jim912様
    早速のご教授、ありがとうございます!!
    素晴らしいプラグインです!!
    思った通りにできました。ありがとうございました。

    しかも、思った以上のことがいろいろできるようで…
    このような素晴らしいプラグインを公開して下さり、感謝です。
    jim912様、ありがとうございます。
    もっと早く知っていれば…

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「カスタム投稿タイプの管理画面でカテゴリーを表示させたい」には新たに返信することはできません。