テーマ制作(6)「カスタム投稿タイプを設定」

カスタム投稿タイプを設定

functions.phpに以下のコードを記述する。


//カスタム投稿タイプ「商品」を追加
add_action( 'init', 'add_post_type_product', 0 );

function add_post_type_product(){
$args = array(
    'labels' => array('name' => '商品'),
    'public' => true,
    'menu_position' =>5,
    'has_archive' => true,
    'taxonomies' => array( 'category', 'post_tag' ),//WPカテゴリー・WPタグ
    'supports' => array('title','editor','excerpt','thumbnail','author'),
);
register_post_type('product', $args);
}

コピーできました!