Invalid taxonomy error when using taxonomy fields
-
Hi, I’m trying use a radio taxonomy field and I keep getting the error below.
Notice: Trying to get property of non-object in /srv/www/oc.com/current/web/app/mu-plugins/cmb2/includes/CMB2_Types.php on line 703
print_r($terms) error msg:
WP_Error Object ( [errors] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy ) ) [error_data] => Array ( ) )I have two custom taxonomies set up and am able to access them via admin..so I believe they are valid.
I’ve tried the custom taxonomy slugs with the other taxonomy fields and keep receiving the same error. ‘categories’ or ‘post_tag’ slugs work.
Here is my code for taxonomies and what I have for the fields.
// Register Custom Taxonomy function oc_listing_type_taxonomy() { $labels = array( 'name' => _x( 'Rent Listing Type', 'Taxonomy General Name', 'text_domain' ), 'singular_name' => _x( 'Rent Listing Type', 'Taxonomy Singular Name', 'text_domain' ), 'menu_name' => __( 'For Rent', 'text_domain' ), 'all_items' => __( 'For Rent', 'text_domain' ), 'parent_item' => __( 'Parent Genre', 'text_domain' ), 'parent_item_colon' => __( 'Parent Genre:', 'text_domain' ), 'new_item_name' => __( 'For Rent', 'text_domain' ), 'add_new_item' => __( 'Add For Rent', 'text_domain' ), 'edit_item' => __( 'Edit For Rent', 'text_domain' ), 'update_item' => __( 'Update For Rent', 'text_domain' ), 'view_item' => __( 'View Item', 'text_domain' ), 'separate_items_with_commas' => __( 'Separate genres with commas', 'text_domain' ), 'add_or_remove_items' => __( 'Add or remove genres', 'text_domain' ), 'choose_from_most_used' => __( 'Choose from the most used genres', 'text_domain' ), 'popular_items' => __( 'Popular Items', 'text_domain' ), 'search_items' => __( 'Search For Rent', 'text_domain' ), 'not_found' => __( 'Not Found', 'text_domain' ), 'no_terms' => __( 'No items', 'text_domain' ), 'items_list' => __( 'Items list', 'text_domain' ), 'items_list_navigation' => __( 'Items list navigation', 'text_domain' ), ); $rewrite = array( 'slug' => 'for_rrent', 'with_front' => true, 'hierarchical' => true, ); $args = array( 'labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => false, 'rewrite' => $rewrite, ); register_taxonomy( 'oc_rent_listing_type', array( 'listings' ), $args ); // Register For Sale Taxonomy $labels = array( 'name' => _x( 'Sale Listing Type', 'Taxonomy General Name', 'text_domain' ), 'singular_name' => _x( 'Sale Listing Type', 'Taxonomy Singular Name', 'text_domain' ), 'menu_name' => __( 'For Sale', 'text_domain' ), 'all_items' => __( 'For Sale', 'text_domain' ), 'pasale_item' => __( 'Pasale Genre', 'text_domain' ), 'pasale_item_colon' => __( 'Pasale Genre:', 'text_domain' ), 'new_item_name' => __( 'For Sale', 'text_domain' ), 'add_new_item' => __( 'Add For Sale', 'text_domain' ), 'edit_item' => __( 'Edit For Sale', 'text_domain' ), 'update_item' => __( 'Update For Sale', 'text_domain' ), 'view_item' => __( 'View Item', 'text_domain' ), 'separate_items_with_commas' => __( 'Separate genres with commas', 'text_domain' ), 'add_or_remove_items' => __( 'Add or remove genres', 'text_domain' ), 'choose_from_most_used' => __( 'Choose from the most used genres', 'text_domain' ), 'popular_items' => __( 'Popular Items', 'text_domain' ), 'search_items' => __( 'Search For Sale', 'text_domain' ), 'not_found' => __( 'Not Found', 'text_domain' ), 'no_terms' => __( 'No items', 'text_domain' ), 'items_list' => __( 'Items list', 'text_domain' ), 'items_list_navigation' => __( 'Items list navigation', 'text_domain' ), ); $rewrite = array( 'slug' => 'for_sale', 'with_front' => true, 'hierarchical' => true, ); $args = array( 'labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => false, 'rewrite' => $rewrite, ); register_taxonomy( 'oc_sale_listing_type', array( 'listings' ), $args ); } add_action( 'init', 'oc_listing_type_taxonomy', 0 );$cmb->add_field( array( 'name' => 'Test Taxonomy Select', 'desc' => 'Description Goes Here', 'id' => 'wiki_test_taxonomy_select', 'taxonomy' => 'for_rrent', //Enter Taxonomy Slug 'type' => 'taxonomy_select', ) );
The topic ‘Invalid taxonomy error when using taxonomy fields’ is closed to new replies.