I am developing a WordPress theme and there I used a custom post type
insurance_all
and a custom taxonomyinsurnce_all_categories
for the post type. But when I try to add a category the AJAX is not working but if I refresh the page the category is loaded. When I want to delete the categoryAn unidentified error has occurred
message show me on the top.My custom post type is
<?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);
My custom taxonomy is
<?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');
Answer
Your taxonomy registration in your example is showing this:
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');?>
and needs to be this:
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');?>
Attribution
Source : Link , Question Author : Moshiur Rahman , Answer Author : stims