当我安装自定义帖子类型作为插件时,它会自动创建3个默认类别,如苹果、索尼、诺基亚。怎么可能呢?我的自定义帖子(&C);分类代码:
function brands() {
$labels = array(
\'name\' => _x( \'Brands\', \'brands_creator\' ),
\'singular_name\' => _x( \'Brand\', \'brands_creator\' ),
\'add_new\' => _x( \'Add New Brand\', \'brands_creator\' ),
\'add_new_item\' => _x( \'Add New Brand\', \'brands_creator\' ),
\'edit_item\' => _x( \'Edit Brand\', \'brands_creator\' ),
\'new_item\' => _x( \'New Brand\', \'brands_creator\' ),
\'view_item\' => _x( \'View Brand\', \'brands_creator\' ),
\'search_items\' => _x( \'Search Brands\', \'brands_creator\' ),
\'not_found\' => _x( \'No Brands found\', \'brands_creator\' ),
\'not_found_in_trash\' => _x( \'No Brands found in Trash\', \'brands_creator\' ),
\'parent_item_colon\' => _x( \'Parent Brand:\', \'brands_creator\' ),
\'menu_name\' => _x( \'Brands\', \'brands_creator\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'description\' => \'Brands filterable by genre\',
\'supports\' => array( \'title\', \'editor\',\'thumbnail\',\'revisions\'),
\'taxonomy\' => \'brand_type\',
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'menu_icon\' =>get_bloginfo(\'url\').\'/wp-content/plugins/brands-creator/images/brand.png\',
\'show_in_nav_menus\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'has_archive\' => true,
\'query_var\' => true,
\'can_export\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\'
);
register_post_type( \'brands_creator\', $args );
}
add_action( \'init\', \'brands\' );
function brand_taxonomy() {
register_taxonomy(
\'brand_type\',
\'brands_creator\',
array(
\'labels\' => array(
\'name\' => \'Brands Type\'
),
)
);
}
add_action( \'init\', \'brand_taxonomy\');
# Default Category that will create automatically#
function default_brand_type() {
wp_insert_term(
\'Example Category\',
\'brand_taxonomy\',
array(
\'description\' => \'MFG Product taxonomy.\',
\'slug\' => \'dmfg\'
)
);
wp_insert_term(
\'EMFG\',
\'brand_type\',
array(
\'description\' => \'EMFG Product taxonomy.\',
\'slug\' => \'demfg\'
)
);
wp_insert_term(
\'OMFG\',
\'brand_type\',
array(
\'description\' => \'OMFG Product taxonomy.\',
\'slug\' => \'domfg\'
)
);
}
add_action( \'after_setup_theme\', \'default_brand_type\' );