“Could not insert term into the database”
-
After setting up a custom post type and taxonomy and linked them together, I get the message “Could not insert term into the database”.
Not sure why, I cannot add new taxonomy entries for some reason, either from the post page or from the taxonomy page.
-
What are the post type and taxonomy slugs you have? what term slug are you trying to use?
General source of the error:
if ( false === $wpdb->insert( $wpdb->terms, $data ) ) { return new WP_Error( 'db_insert_error', __( 'Could not insert term into the database.' ), $wpdb->last_error ); }So it’d seem some part of
$dataisn’t being liked.Post Type:
{“aktivitet”:{“name”:”aktivitet”,”label”:”Aktiviteter”,”singular_label”:”Aktivitet”,”description”:””,”public”:”true”,”publicly_queryable”:”true”,”show_ui”:”true”,”show_in_nav_menus”:”false”,”show_in_rest”:”true”,”rest_base”:””,”rest_controller_class”:””,”has_archive”:”false”,”has_archive_string”:””,”exclude_from_search”:”true”,”capability_type”:”post”,”hierarchical”:”false”,”rewrite”:”true”,”rewrite_slug”:””,”rewrite_withfront”:”true”,”query_var”:”true”,”query_var_slug”:””,”menu_position”:””,”show_in_menu”:”true”,”show_in_menu_string”:””,”menu_icon”:””,”supports”:[“title”,”editor”,”thumbnail”,”excerpt”],”taxonomies”:[“activity_tags”],”labels”:{“menu_name”:””,”all_items”:””,”add_new”:””,”add_new_item”:””,”edit_item”:””,”new_item”:””,”view_item”:””,”view_items”:””,”search_items”:””,”not_found”:””,”not_found_in_trash”:””,”parent_item_colon”:””,”featured_image”:””,”set_featured_image”:””,”remove_featured_image”:””,”use_featured_image”:””,”archives”:””,”insert_into_item”:””,”uploaded_to_this_item”:””,”filter_items_list”:””,”items_list_navigation”:””,”items_list”:””,”attributes”:””,”name_admin_bar”:””},”custom_supports”:””}}
Taxonomy:
{“activity_tags”:{“name”:”activity_tags”,”label”:”Activity tags”,”singular_label”:”Activity tag”,”description”:””,”public”:”true”,”publicly_queryable”:”true”,”hierarchical”:”false”,”show_ui”:”true”,”show_in_menu”:”true”,”show_in_nav_menus”:”true”,”query_var”:”true”,”query_var_slug”:””,”rewrite”:”true”,”rewrite_slug”:””,”rewrite_withfront”:”1″,”rewrite_hierarchical”:”0″,”show_admin_column”:”false”,”show_in_rest”:”true”,”show_in_quick_edit”:””,”rest_base”:””,”rest_controller_class”:””,”labels”:{“menu_name”:””,”all_items”:””,”edit_item”:””,”view_item”:””,”update_item”:””,”add_new_item”:””,”new_item_name”:””,”parent_item”:””,”parent_item_colon”:””,”search_items”:””,”popular_items”:””,”separate_items_with_commas”:””,”add_or_remove_items”:””,”choose_from_most_used”:””,”not_found”:””,”no_terms”:””,”items_list_navigation”:””,”items_list”:””},”meta_box_cb”:””,”object_types”:[“aktivitet”]}}
Thus far not managing to recreate. Managed to create a tag during the creation/editing of a post, and then also from the term management screen for the taxonomy.
At least at this point, I don’t think it necessarily has anything to do with CPTUI, but more something from the rest of your site somehow interfering with the process. However, I can’t say what, by any means.
I can try again if you provide the term you were trying with, just in case it’s somehow playing its own part, but “test” and “test-tag” proved to be no issue.
I see, I will try some more. perhaps some way I can debug what is going on?
My best suggestions for this one would be, if possible, disable plugins until you’re finding the issue goes away, at which point you’d have a good idea of what’s probably causing the issue.
If you’re set up enough to have a local/dev copy of the site that is experiencing the same issues, and perhaps have a tool like XDebug available, you could pause the execution of PHP at the right time and check conditions for it.
Unsure which option will resonate more with you.
Did you ever solve this one @orjanvgmailcom ?
The topic ‘“Could not insert term into the database”’ is closed to new replies.