如果要在调用时使用内置WordPress类别register_post_type 具有的函数taxonomies
参数设置为category
如果要创建自定义类别,请使用register_taxonomy 函数注册一个全新的分类法,并将第二个参数作为自定义帖子类型名称,然后将其分类法名称传递给register_post_type
如上所述。
样本应该是这样的
$args = array(
\'label\' => __( \'Book\' ),
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'book\' ),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'taxonomies\' => array(\'language\'),
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\' )
);
register_taxonomy(
\'language\',
\'book\',
array(
\'label\' => __( \'Language\' ),
\'rewrite\' => array( \'slug\' => \'language\' ),
\'hierarchical\' => true,
)
);
register_post_type( \'book\', $args );