Support » Fixing WordPress » restore category and associated posts

  • hi all,

    i accidentally deleted one of my categories:(. it had many posts attached to it.

    i can add the category back, but the posts are not assigned to it. i have a ton of posts spanning years, so it’s impossible for me to remember which ones were assigned to this category.

    I have a db backup, but don’t want to replace the entire thing since there have been many other changes since the backup.

    is there a simple way to get the category and assigned posts back without restoring the entire database?


Viewing 2 replies - 1 through 2 (of 2 total)
  • found this and used the following query to restore my deleted category with the correct ID, replacing the ID, name, and slug with my own, but the restored category has 0 posts assigned to it:(

    INSERT wp_terms(term_id, <code>name</code>, 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);

    been looking around and if i can just replace my existing posts with the ones that reside in my db backup, i think i’ll be in the clear.

    this way the newer posts would remain, i would just be updating old posts to include my old cat ID (they all changed to Uncategorized when the cat was deleted).

    what would be the best way to do this?

    thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘restore category and associated posts’ is closed to new replies.