LoginSignup
2
2

More than 5 years have passed since last update.

カスタム投稿タイプを作成するサンプル

Posted at
functions.php

// カスタム投稿タイプ
add_action('init', 'register_post_type_and_taxonomy');

function register_post_type_and_taxonomy(){
  register_post_type(
    'works',
    array(
      'labels' => array(
        'name' => 'works',
        'add_new_item' => '新規追加',
        'edit_item' => '編集'
      ),
      'public' => true,
      'hierarchical' => true,
      'has_archive' => true,
      'menu_position' => 5,      
      'supports' => array(
        'title',
        'editor',
        'excerpt',
        'custom-fields',
        'thumbnail',
        'page-attributes'
      )
    )
  );
}

functions.phpでregister_post_typeメソッドを使用する。
定義したらadd_action('init')で起動するように設定する。

参照) http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/register_post_type

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2