I am facing a wired issue where the featured image is not getting updated properly if the id of the attachment was updated during import Here is the scenario.
Assume that you have exported content from an old site. A post (assume the id is 1000) has a featured image (attachment id is 1001).
Now we are trying to import it into a new site. Assume that in the new site the wp_posts
table has ids till 1500.
When the import imports the attachment, the new id of the attachment will be 1501. The new id of the post will be 1502.
But in the post with id 1502, the post meta key _thumbnail_id
is still set to 1001 and is not updated to 1501.
Because of this, the featured image doesn't work for the newly imported post. Is there a way to handle this id clash?