我的问题是“自定义帖子类型”,其中包含用于对其进行分类的字段。我找不到任何解决方案,希望我能在这里为我提供帮助。
自定义帖子类型称为“ TEAM”,需要具有类别“ STAFF”,“ GUESTS”和“ ARTISTS”的向下滚动菜单。我已经阅读了很多有关自定义分类法的信息,但我确实不了解。
function register_team_post_type() {
$labels = array(
'name' => 'Team',
'singular_name' => 'Team',
'add_new' => 'Add New Team',
'add_new_item' => 'Add New Team',
'edit_item' => 'Edit Team',
'new_item' => 'New Team',
'all_items' => 'All Team Post',
'view_item' => 'View Team',
'search_items' => 'Search Team',
'not_found' => 'No Team found',
'not_found_in_trash' => 'No Team found in Trash',
'parent_item_colon' => '',
'menu_name' => 'Team Post'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => (is_super_admin()) ? true : false,
'query_var' => true,
'rewrite' => array( 'slug' => 'team' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 6,
//'taxonomies' => array('category'),
'supports' => array( 'title', 'editor', 'author', 'custom-fields', 'comments' )
);
register_post_type( 'team', $args );
}
add_action( 'init', 'register_team_post_type' );
add_action( 'init', 'register_team_category', 0 );
function register_team_category() {
register_taxonomy( 'categories', 'team', array( 'hierarchical' => true, 'label' => 'Team Categories', 'query_var' => true, 'rewrite' => true ) );
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句