I am having problem when creating term with same slug in different taxonomies. I researched that Unique key is removed from slug in wp_terms table, so i am getting problem to figure out that why i am getting this problem and also i am can still see Unique key in WordPress database.

enter image description here

For ref:

  1. https://core.trac.wordpress.org/ticket/22023#comment:49

  2. https://codex.wordpress.org/Function_Reference/wp_unique_term_slug


[05-May-2016 12:17:49 UTC] WordPress database error Duplicate entry '05-yhoo-commentary' for key 'slug' for query INSERT INTO wp_terms (name, slug, term_group) VALUES ('Deal Commentary & Pitch Book', '05-yhoo-commentary', 0) made by do_action('wp_ajax_inline-save-tax'), call_user_func_array, wp_ajax_inline_save_tax, wp_update_term, _split_shared_term

  • 1
    Is your WP install up to date? Check your indexes (small link under that structure table), does slug have UNIQUE index? If yes, change index to normal INDEX. Column should be slug[varchar(200)] and size 191 – N00b May 5 '16 at 14:33
  • @TwerkingN00b This image is from latest wordpress install. – Ravinder Kumar May 5 '16 at 15:03
  • 1
    Did you check the indexes of that table? – N00b May 5 '16 at 15:08
  • @TwerkingN00b yes slug has UNIQUE index. Why WordPress did not change this? if i change this to index will it break anything – Ravinder Kumar May 5 '16 at 15:28
  • Im not sure why it didn't change that.. I have it as INDEX and I have no idea what effect could it have to your system. There's only one way to find out.. Don't forget to backup your database! – N00b May 5 '16 at 15:31

Was having the same problem on a couple of sites myself, but this thread not only gave me the answer, but hinted at why it had been happening :)

I create a new user for each database, with only permissions to that database, however even within that (given I don't do it often) I guess what perms they'll need to that database as I'm creating the user and blank database for the new WP site. Seems if you don't give the user adequate permissions to the database, on the occasions WP updates change tables those table changes can fail while the WP site will assume they've succeeded and behave accordingly (e.g. ALTERing a table for the slug field index).

I didn't bother to note which specific permission was missing, just gave the user most permissions for the database, and presto (as other permissions may occasionally be needed for other WP updates to work).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.