How to Disable the Media Attachment Pages in WordPress

>How to Disable the Media Attachment Pages in WordPress
  • How to Disable the Media Attachment Pages in WordPress

When you upload a media file, like an image or a video, WordPress will create its own attachment page, just like a normal page.

The bad news is that this page will be published by default, which means that it can be accessed by the general public. You don’t need to attach the media file to a post or page in order for it to be visible.

Most of you will want to prevent that from happening, either because you have a media file that you don’t want to be accessed by everybody, or because the attachment page looks pretty bad, since theme developers don’t pay any attention to it.

Here’s an example of how it looks like:

WordPress attachment page

It looks pretty weird, no? Just the file, its title, your sidebar, comment area…

Therefore, in this article, I’ll show you how to disable the attachment pages in WordPress with one of these two plugins.

Disable media attachment pages with the “Yoast SEO” plugin

For those of you which are using the Yoast SEO plugin — and all of you should use it because it will make your life so much easier, not just for SEO; it’s a must-have plugin — you just need to activate an option.

  • Go to SEO -> Advanced;
  • Select the Permalinks tab;
  • Select the Redirect option under Redirect attachments URLs to parent post URL;
  • Save.

Redirect attachment page with Yoast SEO

If you enable that, the attachment page will be redirected to the parent post.

Nice and easy, no?

Disable media attachment pages with the “Attachment Pages Redirect” plugin

For those of you that don’t have Yoast installed, and don’t want to have it either, especially for just one feature, then install Attachment Pages Redirect, which handles just that.

Once activated, it will perform a 301 redirect (permanent redirect) from the attachment page to the parent post, if the media file is attached there. If it’s not attached, then it will perform a 302 redirect (temporary redirect) to your homepage.

The plugin doesn’t have any settings. You just have to activate it, that’s it.

That’s a wrap

Hope you found the post useful!

Don’t forget to share it with your friends!

If you have any questions or thoughts, drop a comment, contact us or message us on Facebook.

By | 2018-02-17T16:25:06+00:00 September 12th, 2017|How to, Plugins, Tips|2 Comments


  1. Turrican December 20, 2017 at 11:39 AM - Reply

    It works but the following page has a normal url like ?page_id=647 and not the permalink like /pagename/. Any ideas?

    • ThemeSkills December 21, 2017 at 6:36 PM - Reply

      I didn’t quite understand what you’re trying to say.

Leave A Comment