How to Disable Image Attachment Pages in WordPress

Disable Image Attachments WordPress

Wondering how WordPress image attachment page could lower your Google rankings? Trying to disable image attachment pages in your WordPress site?  

Whenever you upload an image to the WordPress media library, WordPress creates a separate media attachment page for your every file. This page has nothing but the media content and an automatically generated URL.

What’s the Problem with Image Attachment?

The attachment page is virtually good-for-nothing as it has no content. This page gets published when you upload an image to the media library can be accessed by anyone. You might consider it a problem for your site. The WordPress attachment pages usually look very bad because these remained far away from proper care by the developers. So, it could easily create a bad impact on your brand image.

Google Indexing and WordPress SEO

Google follows its own algorithm for page ranking. If you ignore disabling WordPress image attachment pages, Google could start indexing these pages. Your site will not get better ranks if Google indexes unnecessary pages/poor content for your website.

Disable Image Attachments in WordPress

Attachment pages can be harmful in a number of ways

  • Misguiding your audiences.
  • Hurting your site’s privacy.
  • Easy target by hackers.
  • Stealing your copyright images.

It’s important to disable WordPress image attachment page in your site. Not only that, you need to redirect the page to your site’s homepage and make your audiences able to land your actual post directly.

We are going to describe some useful ways to disable the WordPress image attachment page on your site. Keep reading.

How to Disable WordPress Image Attachment Page

You can disable WordPress image attachment pages using

  1. Plugins
  2. Manually with code
  3. From WordPress Settings

Also, you can solve the problem by making some changes in the setting option of your site. We are going to show you two easiest but proven ways to disable image attachment page in WordPress.

1. Yoast SEO

Yoast SEO is one of the most useful WordPress original plugins. It’s not only important for your site’s SEO, but it will also help you to make your web life easier and secure.

Yoast SEO- wordpress image attachment page

You can disable WordPress image attachment page using this awesome plugin. It’s easy and free for you!

How to activate Yoast SEO?

If you know how to add a plugin to your site, then all you need to do is to install Yoast by searching from plugins. If you already have the plugin then you just need to activate an option to disable image attachment pages.  If you don’t have it yet, just go to your dashboard and install it by clicking on Add Plugin button.

Now,  follow the instructions to remove the image attachment page from indexing.

  • Go to Search Appearance- Yoast SEO
  • Select the Media tab
  • Select YES option, marked in below screenshot.
  • And finally hit on Save changes button.
Disabling image attacment- wordpress image attachment page

The plugin will redirect the WordPress attachment page to your media file automatically. And you are now free from all sorts of tension!

2. WordPress Pages Redirect

You will find lots of attachment redirect plugins on WordPress’s plugin search bar. Install any of them, and you can redirect attachment pages by using them.Attachment pages- WordPress image attachment pageWe are here going to show you how to disable WordPress image attachment page using plugins. We have selected the plugin “Attachment Pages Redirect” as an example.

 Attachment Pages Redirect in Action!

Attachment Pages Redirect is a WordPress redirection plugin. It’s one of the easiest but most useful ways to disable the image attachment pages.

Why it’s the best?

  • You can just add and it will take care of the rest.
  • Doesn’t increase your site’s loading time.
  • Doesn’t hurt the SEO of your site.
How to Install Attachment Pages Redirect?

Go to your site’s backend and click on the Add Plugin button. It will automatically redirect you to the plugin search page.

Now, write the plugin name “Attachment Pages Redirect” on the search option. You should see the plugin installation option within a few moments. And after that just click on the Install button.

Attachment pages redirect- WordPress image attachment page

Once you completed the installation, click on the Activate button.  And you are done! The plugin will automatically disable WordPress image attachment page in your site!

How does Attachment Pages Redirect work?

It simply implements a redirect from the attachment page to the actual post. This plugin works when the actual article exists in the right place. Also, when your article is scrapped in the trash folder but not deleted and even if your article is permanently deleted!

If your article was deleted permanently but not the attachment, the plugin implements a temporary redirect to your homepage. You could detect this problem by monitoring your site’s analytics or the sources of your traffic. When you find such a problem, you should either replace the article or remove the image attachment page.

Attachment pages redirect- WordPress image attachment page

install WordPress Attachment Plugin. It’s totally free! Easy to add and obviously an ideal solution to help prevent the issues.

Is it possible to disable WordPress image attachment page without using plugins?

Yes, it’s surely possible to disable WordPress image attachment pages and redirect them to the actual post using a code. You too could disable these pages completely! You need to have some technical knowledge and copy a code every time you upload an image or video.

It can be good but time-consuming. You should prefer using a plugin. It’s easy, secured and of course free as we mentioned earlier!

Before Ending

It can be a little bit tricky for beginners but not so hard. You can disable WordPress image attachment pages in your site by only adding a plugin. It’s important because it might directly affect your site’s SEO ranking. Moreover, this could misguide your audiences anytime and that will certainly result on your traffics.

We hope you have found this guideline helpful to solve your problem. Like this, you should always be aware of your site’s security, You could also check out some awesome websites built with WordPress and get to learn why to prefer WordPress for your business!

Wordpress Icon

Disclosure: WP Hive earns a commission when you buy through partner links. It does not influence the unbiased opinions of our writers. Learn more →

Share: icon

Saif Hassan

Product Manager by passion & profession. Lead Product Manager at weDevs, former PM @ Poptin. Passionate about writing & tech. He's an advocate of Human-Centered Design and believes that websites and the tools used to build them should be well crafted, intuitive, and accessible. Cyclist. Reader. A WordPress ninja 🥷, HCI expert & a design thinker 💡

Subscribe To Our Newsletter

Newsletter Subscription Form


Editorial Stuff

1. Create a child theme.
2. Create file named image.php inside your child theme.
3. Write the following code in the image.php file. This will completely disable the attachment page.

global $post;
if ( $post && $post->post_parent ) {
	wp_redirect( esc_url( get_permalink( $post->post_parent ) ), 301 );
} else {
	wp_redirect( esc_url( home_url( '/' ) ), 301 );

Hello Saif and thanks for this article.

Unfortunately, I didn’t know it and some of the images on my website are indexed as separate pages. Now I activate it in the plugin.

I want to know how can I remove those previous url images that are indexed as separate pages?
Is it automatically deleted by Google in the next crawling?