カテゴリありのカスタム投稿の設定

カテゴリありのカスタム投稿の設定
カテゴリありのカスタム投稿の設定します。
下記コードをfunction.phpに追記。
// カスタム投稿の追加 add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'カスタム投稿名', array( //ダッシュボード 'labels' => array( 'name' => __( 'カスタム投稿名' ), ), 'public' => true, 'menu_position' => 5, 'supports' => array( 'title', 'editor', 'thumbnail' ), 'has_archive' => true, //アーカイブページを生成 ) ); //カテゴリの設定 register_taxonomy( 'カテゴリー名', 'カスタム投稿名', array( 'hierarchical' => true, //カテゴリータイプの指定 'update_count_callback' => '_update_post_term_count', //ダッシュボード 'label' => 'お知らせのカテゴリー', 'public' => true, 'show_ui' => true ) ); }
関連記事