So, somehow after many migrations i ended up with thousands of featured images that are unattached. They exist in the media library and are used as featured images of the articles but they are not attached to those articles. In other words their post_parent = 0.
I need a way to reattach those images to the posts they are set as featured image.
So for each image with post_parent = 0, i have to find the post_id of were they are featured and update post_parent of the attachment to match the post ID.
I'm not a programmer, i understand what needs to be done but i don't know how to code it. If anyone can help with an example it'll be great. thanks!