2016-06-30 27 views
0

このサンプルのようなカテゴリのカスタム投稿タイプを作成するにはどうすればよいですか。入力ボックスにテキストを入力し、カテゴリ名として取得します。カテゴリーのカスタム投稿タイプを作成

public function panotour_register_post_type(){ 
    register_post_type(self::$custom_post_type,array(
      'taxonomies' => array('category'), 
      'name'   => 'CategoryName', 
      'hierarchical' => true, 
      'query_var' => true 
     ) 
    ); 
} 
+0

? – purvik7373

答えて

0

**あなたは**カスタム分類カスタムポストタイプへの変換もしかしてカスタムポストタイプを作成して分類法を使用して、カテゴリにそのポストタイプを追加し、

function create_post_type() { 
    $args = array(
     'label'    => __('cpost', 'twentythirteen'), 
     'description'   => __('Custom Post Type', 'twentythirteen'), 
     'supports'   => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields',), 
     'hierarchical'  => false, 
     'public'    => true, 
     'show_ui'    => true, 
     'show_in_menu'  => true, 
     'show_in_nav_menus' => true, 
     'show_in_admin_bar' => true, 
     'menu_position'  => 5, 
     'can_export'   => true, 
     'has_archive'   => true, 
     'exclude_from_search' => false, 
     'publicly_queryable' => true, 
     'capability_type'  => 'page', 
     'taxonomies'   => array('category_name'), 
    ); 

    // Registering Custom Post Type 
    register_post_type('cpost', $args); 

} 

add_action('init', 'create_post_type', 0); 
+0

ありがとうPHPのユーザーこれは素晴らしいと完璧ですが、私が欲しいものは、カテゴリ名として入れられる名前だけです。たとえば、私は学校、アパート、モールを入力し、このことは投稿のカテゴリになります。これは可能ですか? – wptour

関連する問題