WordPress.org

Ready to get started?Download WordPress

Forums

restore category and associated posts (3 posts)

  1. BSK
    Member
    Posted 2 years ago #

    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?

    thanks!!!

  2. BSK
    Member
    Posted 2 years ago #

    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);
  3. BSK
    Member
    Posted 2 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic