I'm working on a site that is using a theme with an attachment.php file in the theme. However, when going to an image's attachment page (i.e. https://domain/john-doe/) it loads the direct image (i.e. https://domain/files/2020/03/john-doe.png).

What would cause this to occur? I thought WordPress would load the attachment URL and present the item as coded in attachment.php, not the media file itself.

  • 1
    It depends on your theme and plugins. If you're using a plugin like Yoast WP SEO, there are settings to disable attachment pages (because they're usually not good for SEO). Check your plugin settings and/or deactivate all plugins, see if you still have the problem, and reactivate one by one to find out which one is the issue.
    – WebElaine
    Mar 24, 2020 at 20:20

1 Answer 1


Thanks @WebElaine.

We're running Yoast SEO so I had another look and saw the setting in Search Appearance > Media (wp-admin/admin.php?page=wpseo_titles#top#media).

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.