我已经注册了一个名为“document”的自定义帖子类型,并希望添加类别支持。
我也明白
register_taxonomy_for_object_type(\'category\',\'document\');
或添加
\'taxonomies\' => array(\'category\',),
在注册post类型时,我的参数应该起作用,但两者都不起作用。我做错了什么?
完整代码如下:
$labels = array(
\'name\' => _x(\'Document\', \'post type general name\', \'creative\'),
\'singular_name\' => _x(\'Document\', \'post type singular name\', \'creative\'),
\'add_new\' => _x(\'Add New\', \'post type new\', \'creative\'),
\'add_new_item\' => __(\'Add New Document\', \'creative\'),
\'edit_item\' => __(\'Edit Document\', \'creative\'),
\'new_item\' => __(\'New Document\', \'creative\'),
\'view_item\' => __(\'View Document\', \'creative\'),
\'search_items\' => __(\'Search Documents\', \'creative\'),
\'not_found\' => __(\'No Documents found\', \'creative\'),
\'not_found_in_trash\' => __(\'No Documents found in Trash\', \'creative\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Documents\'
);
$args = array(
\'labels\' => $labels,
\'taxonomies\' => array(\'category\',),
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'has_archive\' => false,
\'hierarchical\' => true,
\'menu_position\' => 20,
\'menu_icon\' => \'dashicons-media-default\',
\'supports\' => array( \'title\', \'editor\', \'thumbnail\' )
);
register_post_type( \'document\', $args);