If you are getting a WordPress media attachment page 404 error, the solution may not be obvious. I got very frustrated with the unhelpful answers found searching on Google, so I dug deep to find my own definitive solution.
After much trial-and-error checking, it appears that the issue is: the media/image file is attached to a post or page that no longer exists. This is a very subtle error, but removing the nonexistent post reference fixed all of my affected image files!
Fix for WordPress Media Attachment Page 404 Error
To see the breakage easily, I made use of a WordPress plugin to show more details about the image file. The plugin was used to visualize the problem (the attachment to the nonexistent post) and can be used to fix the attachment issue. In my case, I deleted the attachment but could have re-attached the image to an existing post.
- Setup the Media Library Assistant plugin under the “General” tab, then scroll to “Media/Edit Media Enhancements.”
- Check the box: “Enable Edit Media additional meta boxes” – this adds “Parent Info,” “Menu Order,” “Attachment Metadata,” and four “where-used” meta boxes to the Edit Media screen.
- Go to each faulty image file and review the “Parent Info” section – observe the NONEXISTENT attachment!
- Fix the attachment as you wish.
Also, go to “Media,” then “Assistant” to observe, under the “Title/Name” column, the status of the media attachment, including UNATTACHED. (This menu item “Assistant” is available with the Media Library Assistant plugin installed.)
How This Happens
Media such as images uploaded by various plugins may create a “Page” or “Collection,” which you may delete later, but keep the image. In my case, I deleted such pages after the fact. The plugins were likely performing as described.
You can use the Media Library Assistant by David Lingren; also look into Media File Renamer by Jordy Meow.
One thought on “WordPress Media Attachment Page 404 Error Fix”
Thank you Thank you….this is the answer I have been looking for.
I am also an engineer / photographer BTW