我创建了一个“视频”自定义帖子类型。
add_action( 'init', 'create_video_postype' );
function create_video_postype() {
$labels = array(
'name' => _x('Videos', 'post type general name'),
'singular_name' => _x('Video', 'post type singular name'),
'add_new' => _x('Add New', 'video'),
'add_new_item' => __('Add New Video'),
'edit_item' => __('Edit Video'),
'new_item' => __('New Video'),
'view_item' => __('View Video'),
'search_items' => __('Search Video'),
'not_found' => __('No Video found'),
'not_found_in_trash' => __('No Video found in Trash'),
'parent_item_colon' => '',
);
$args = array(
'label' => __('Videos'),
'labels' => $labels,
'public' => true,
'can_export' => true,
'show_ui' => true,
'_builtin' => false,
'capability_type' => 'post',
'rewrite' => array( "slug" => 'video' ),
'query_var' => true,
'menu_icon' => '',
'hierarchical' => true,
'supports'=> array('title', 'thumbnail', 'excerpt', 'editor', 'page-attributes') ,
'show_in_nav_menus' => true ,
'taxonomies' => array('category')
);
register_post_type( 'video', $args);
}
我需要获取“视频”帖子中使用的所有类别。当我使用这个函数 get_categories() 时,它会返回 post 使用的所有类别。