'WordPress: Images classified as unattached but they are uploaded to posts
In WordPress, when an image is assigned as a featured image to a post, and then that post is deleted, it becomes an unattached image. It remains unattached even if it's used again in a new post.
This is problematic in my site's workflow. I wrote a script to remove unattached images (to save server space), but it gets rid of images that technically are uploaded to posts, but listed as unattached.
Is there a way to programmatically loop through all unattached media and assign their post_parent to the post they are actually uploaded to? That way they would no longer appear to be unattached.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
