Stupidly, I truncated my posts table with out thinking about the term relationships. Now I have a bunch of 404s because there are broken term relationships. Is is possible to rebuild the table with the correct pairings?

2 Answers
2

If your AUTO_INCREMENT value wasn’t reset and your new posts will still have unique IDs and you can do:

SELECT tr.*, p.ID
FROM wp_term_relationships AS tr
    LEFT JOIN wp_posts AS p ON tr.object_id = p.ID
WHERE p.ID is NULL;

to see which term relationships are orphans and use a DELETE FROM to fix it.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *