我已经创建了一个自定义帖子类型“hotel”和自定义“taxonomy”,所以当管理员创建一个新酒店并保存它时,会自动创建相关的自定义分类,但我不想在管理端的酒店编辑页面中显示自定义元框,因此我使用了WordPress功能,但什么都没有发生。
我的自定义邮政编码
$Hotel_labels = array(
\'name\' => _x(\'Hotels\', \'post type general name\'),
\'singular_name\' => _x(\'Hotel\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'Hotel\'),
\'add_new_item\' => __(\'Add Hotel\'),
\'edit_item\' => __(\'Edit Hotel\'),
\'new_item\' => __(\'New Hotel\'),
\'all_items\' => __(\'All Hotels\'),
\'view_item\' => __(\'View Hotel\'),
\'search_items\' => __(\'Search Hotel\'),
\'not_found\' => __(\'No Hotel found\'),
\'not_found_in_trash\' => __(\'No Hotel found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => __(\'Hotel\'),
);
register_post_type(\'Hotel\',$Hotel_args);
自定义分类代码
$Package_labels = array(
\'name\' => _x( \'Package Hotels\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'hotel\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search hotels\' ),
\'popular_items\' => __( \'Popular hotels\' ),
\'all_items\' => __( \'All hotels\' ),
\'parent_item\' => null,
\'parent_item_colon\' => null,
\'edit_item\' => __( \'Edit hotel\' ),
\'update_item\' => __( \'Update hotel\' ),
\'add_new_item\' => __( \'Add New hotel\' ),
\'new_item_name\' => __( \'New hotel Name\' ),
\'separate_items_with_commas\' => __( \'Separate hotels with commas\' ),
\'add_or_remove_items\' => __( \'Add or remove hotels\' ),
\'choose_from_most_used\' => __( \'Choose from the most used hotels\' ),
\'menu_name\' => __( \'Package Hotels\' ),
);
register_taxonomy(\'package_hotel\',\'package\',array(
\'hierarchical\' => false,
\'labels\' => $Package_labels,
\'show_ui\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'query_var\' => true,
\'show_in_nav_menus\' => false,
\'rewrite\' => array( \'slug\' => \'hotels\' ),
));
从自定义post type hotel页面中删除自定义分类metabox的代码
function my_remove_meta_boxes() {
remove_meta_box(\'tagsdiv_hotels\', \'Hotel\', \'side\');
}
add_action( \'admin_menu\', \'my_remove_meta_boxes\' );