当你register_taxonomy 只需将post\\u类型的数组添加到$object_type
参数
来自WordPress codex:
(数组/字符串)(必需)分类法对象的对象类型的名称。对象类型可以是内置对象(见下文)或任何可以注册的自定义帖子类型。
因此,您可以在运行后添加一个post\\u类型数组register_taxonomy
在本例中,其名称为“流派”。请参见下面的代码:
//hook into the init action and call create_book_taxonomies when it fires
add_action( \'init\', \'create_book_taxonomies\', 0 );
//create genres for the post_types post and page
function create_book_taxonomies() {
$labels = array(
\'name\' => _x( \'Genres\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Genre\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Genres\' ),
\'all_items\' => __( \'All Genres\' ),
\'parent_item\' => __( \'Parent Genre\' ),
\'parent_item_colon\' => __( \'Parent Genre:\' ),
\'edit_item\' => __( \'Edit Genre\' ),
\'update_item\' => __( \'Update Genre\' ),
\'add_new_item\' => __( \'Add New Genre\' ),
\'new_item_name\' => __( \'New Genre Name\' ),
\'menu_name\' => __( \'Genre\' ),
);
register_taxonomy(
\'genre\',
array(\'post\', \'page\'), // add your post_types here
array(
\'hierarchical\' => false,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'genre\' ),
));
}
然后你分享了相同的剂量数据
post_types
.