WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a plugin that expects there to be a default "uncategorized" category with ID=1. I've inadvertantly deleted the uncategorized category. Is it possible to recreate the category as ID=1?

When I look at a default WP install, I see that the table "wp_terms" has uncategorized as the first record with id 1. It also appears that the "wp_term_relationships" and "wp_term_taxonomy" tables are in play in this regard.

How would one go about recreating this category?

share|improve this question
up vote 3 down vote accepted

You need 3 steps:

1.Creating a term in wp_terms with ID is 1

2.Insert a term_taxanomy into wp_term_taxonomy with term_id is 1, and taxonomy must be category

3.Insert a term_relationships into wp_term_relationships with object_id is 1 and term_taxonomy_id is 1 Run below code in PHPMYADMIN to re-create this category!

INSERT wp_terms(term_id, `name`, slug) VALUES (1, 'Uncategorize', 'uncategorized');
INSERT wp_term_taxonomy(term_taxonomy_id, term_id, taxonomy, parent) VALUES (1, 1, 'category', 0);
INSERT wp_term_relationships(object_id, term_taxonomy_id, term_order) VALUES (1, 1, 0);
share|improve this answer
Thanks. Exactly what I was looking for. In this case, it will be a one off to fix this website. Can I call these inserts directly from my plugin script or do I need to establish a connection to wpdb global? – Scott B Dec 14 '10 at 15:46
You can run it directly on PHPMYADMIN! Or use global $wpdb object and call query method: $wpdb->query() – kureikain Dec 14 '10 at 21:14

Could your plugin not use get_option('default_category'), which returns the ID of the default category?

share|improve this answer
To compliment this answer: If a plugin maintained by someone else is hard-coding this value and it's part of a callback function, you can always unhook that callback and replace it with your own copy until such time the plugin is coded better. – t31os Dec 14 '10 at 11:27

It's an auto incrementing integer, so you can't using WP. But you can edit the term id and its taxonomy id from the database directly.

share|improve this answer
INSERT INTO wp_terms (term_id, name, slug) VALUES (1, 'Uncategorized', 'uncategorized'). Sometimes it's not feasible to update the existing code, whether or not it's the "right" thing to do. – Annika Backstrom Dec 14 '10 at 2:34

Either recreate it directly in the database by copying another one in and editing it, OR, why not check in your plugin files? Just do a file search for the id=1 thing and see what you come up with, and then change that to your new default id #. I always find it's easier to edit plugin and php files than mucking around in the database.

share|improve this answer
I kinda (sorta) like the first part of this answer, but not so much the second part because any update to the plugin is going to re-break the site. The best solution would be for the plugin to allow setting the default category as opposed to making the completely arbitrary decision that it's the first one you thought to create. But that means getting the plugin author to fix it ... not always an easy thing to do. – Peter Rowell Dec 14 '10 at 2:13
Peter, I agree. I should have mentioned that in my post. It would have been nice for the plugin to have given that option, but it's still a viable option for the user so long as they're aware that any future updates would possibly break it. Sometimes it's worth making a change like that. The OP has to weigh that in his decision. – RodeoRamsey Dec 14 '10 at 4:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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