WordPress Media Attachment Page 404 Error

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

In order to see the breakage easily, I made use of a WordPress plugin to show more details about the image file. The plugin was used for visualizing the problem (the attachment to the nonexistent post), and can be used to actually fix the attachment issue. In my case, I removed the attachment completely, but could have re-attached the image to an existing post.

  1. Setup the Media Library Assistant plugin under the “General” tab, then scroll to “Media/Edit Media Enhancements”.
  2. 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.
  3. Go to each faulty image file and review the “Parent Info” section – observe NONEXISTENT attachment!
  4. 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.

Recommended Tools

You can use the Media Library Assistant by David Lingren; also look into Media File Renamer by Jordy Meow.

Program Code

DreamHost Disclaimer in CSS

Here is a DreamHost disclaimer written in CSS div.post div.entry div.disclaimer { width:95%; font-size:1em; background-color:#ffeeee; border:1px solid #990000; padding:1.5em; margin:1em 0; } […]

Leave a comment

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

One thought on “WordPress Media Attachment Page 404 Error”