我正在开发一个WordPress主题,在那里我使用了自定义的帖子类型insurance_all
和自定义分类法insurnce_all_categories
对于职位类型。但是,当我尝试添加一个类别时,AJAX不起作用,但如果我刷新页面,就会加载该类别。当我要删除类别时An unidentified error has occurred
消息显示在顶部。
我的自定义帖子类型为
<?php
$insurnce_all_labels = array(
\'name\' => _x( \'Insurance all \', \'Post Type General Name\', \'safest\' ),
\'singular_name\' => _x( \'Insurance all \', \'Post Type Singular Name\', \'safest\' ),
\'menu_name\' => __( \'Insurance all\', \'safest\' ),
\'name_admin_bar\' => __( \'Insurance all\', \'safest\' ),
\'archives\' => __( \'Insurance all Archives\', \'safest\' ),
\'parent_item_colon\' => __( \'Insurance all parent item:\', \'safest\' ),
\'all_items\' => __( \'Insurance all\' , \'safest\' ),
\'add_new_item\' => __( \'Add new item\', \'safest\' ),
\'add_new\' => __( \'Add new\', \'safest\' ),
\'new_item\' => __( \'Add new item\', \'safest\' ),
\'edit_item\' => __( \'Edit item\', \'safest\' ),
\'update_item\' => __( \'Update item\', \'safest\' ),
\'view_item\' => __( \'View item\', \'safest\' ),
\'search_items\' => __( \'Search item\', \'safest\' ),
\'not_found\' => __( \'Not found\', \'safest\' ),
\'not_found_in_trash\' => __( \'Not found in trash\', \'safest\' ),
\'insert_into_item\' => __( \'Insert into item\', \'safest\' ),
\'uploaded_to_this_item\' => __( \'Uploaded this item to Insurance all section\', \'safest\' ),
\'items_list\' => __( \'Insurance all\', \'safest\' ),
\'items_list_navigation\' => __( \'Insurance all section list navigation\', \'safest\' ),
\'filter_items_list\' => __( \'Filter Insurance all section list \', \'safest\' ),
);
$insurnce_all_args = array(
\'label\' => __( \'Insurance all\', \'safest\' ),
\'description\' => __( \'Safest Insurance Insurance all for insurance menu\', \'safest\' ),
\'labels\' => $insurnce_all_labels,
\'supports\' => array(\'title\',\'page-attributes\',\'thumbnail\',\'categories\',),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'menu_position\' => 8,
\'menu_icon\' => \'dashicons-menu\',
\'show_in_admin_bar\' => true,
\'show_in_nav_menus\' => true,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'post\',
);
register_post_type(\'insurance_all\', $insurnce_all_args);
我的自定义分类是
<?php
function insurance_all_category() {
$labels = array(
\'name\' => _x( \'Insurance all category\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Category\' ),
\'all_items\' => __( \'All Categories\' ),
\'parent_item\' => __( \'Parent Category\' ),
\'parent_item_colon\' => __( \'Parent Category:\' ),
\'edit_item\' => __( \'Edit Category\' ),
\'update_item\' => __( \'Update Category\' ),
\'add_new_item\' => __( \'Add New Category\' ),
\'new_item_name\' => __( \'New Category\' ),
\'menu_name\' => __( \'Categories\' ),
);
register_taxonomy(\'insurnce_all_categories\', array(\'insurance_all\'),$args);
}
add_action(\'init\',\'insurance_all_category\');
SO网友:stims
示例中的分类法注册显示了以下内容:
function insurance_all_category(){
$labels = array(
\'name\' =>_x( \'Insurance all category\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Category\' ),
\'all_items\' => __( \'All Categories\' ),
\'parent_item\' => __( \'Parent Category\' ),
\'parent_item_colon\' => __( \'Parent Category:\' ),
\'edit_item\' => __( \'Edit Category\' ),
\'update_item\' => __( \'Update Category\' ),
\'add_new_item\' => __( \'Add New Category\' ),
\'new_item_name\' => __( \'New Category\' ),
\'menu_name\' => __( \'Categories\' ),
);
register_taxonomy(\'insurnce_all_categories\', array(\'insurance_all\'),$args);}add_action(\'init\',\'insurance_all_category\');?>
需要这样:
function insurance_all_category(){
$labels = array(
\'name\' =>_x( \'Insurance all category\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Category\' ),
\'all_items\' => __( \'All Categories\' ),
\'parent_item\' => __( \'Parent Category\' ),
\'parent_item_colon\' => __( \'Parent Category:\' ),
\'edit_item\' => __( \'Edit Category\' ),
\'update_item\' => __( \'Update Category\' ),
\'add_new_item\' => __( \'Add New Category\' ),
\'new_item_name\' => __( \'New Category\' ),
\'menu_name\' => __( \'Categories\' ),
);
//new code
$args = array(
\'labels\' => $labels
);
register_taxonomy(\'insurnce_all_categories\', array(\'insurance_all\'),$args);}add_action(\'init\',\'insurance_all_category\');?>