Recently I’ve ran into a serious pickle – WordPress menu disappeared on me after adding new items and clicking on “Save menu” button.
Naturally, I’ve tried increasing “max_input_vars” cause WordPress is known to be messing up menus with large items (menu in question had 89 items). But this didn’t help.
So, I’ve started debugging and found out that my taxonomy term (“nav_menu”) still exists in DB but it has gotten new term linked to it (WordPress created new entry in the wp_terms table and naturally didn’t transfer object relationships)! Upon closer inspection I’ve found out that one term was part of two taxonomies! I’ve had a “Clusters” post category and “Clusters” name menu. I guess WordPress merged this in some of their update in the past (cause it was working before).
Once I’ve discovered this, the fix was quick. You just need to point (newly created term) to one of the taxonomy term entry.
So for example, my menu term had ID of 61 and my post category had ID 67. In wp_term_taxonomy table they were both having the same term_id (61) but naturally different term_taxonomy_id. I’ve updated the wp_term_taxonomy_table and set term_id 97 (newly created term) where term_taxonomy_id was 67 (post category).
And voilà, everything worked. Posts were pointed correctly in wp_term_relationships table (to term_taxonomy_id) so we didn’t need to update that as well. Simple and quick fix but one that is hard to find and pinpoint. Hope that it will save you a couple of hours (that I’ve spent on debugging) if you ran into a similar issue.