WordPress Attachment Pages – Traps And Pitfalls

Some bloggers with plenty of WordPress experience suddenly discover the attachment pages phenomena. Attachment pages are individual pages created for each media file that you upload on a website. They are hidden from the frontend, so neither users nor website owners see it. However, if you go to the admin dashboard and look for attachment pages you will discover them and see that they are blank.

Check for yourself:

  • Go to the admin dashboard. Open Media and select any image.

Remove WordPress Attachment Pages And Hide Useless Webpages From Search Results

The window with the detailed image information displays. Now follow the link View Attachment page. Here, you will see a blank page that wastes website space.

Remove WordPress Attachment Pages And Hide Useless Webpages From Search Results

Some think that attachment pages are made for users’ comments on each image or video. The user could do so by following the link from the search engine, instead of opening a direct post.

SEO specialists call those pages optimization pitfalls for a reason. Attachments generated automatically can be indexed by search engines shortly. And here they are – competing with a direct page of the post for ranking positions. As we all know, post pages are the source of useful information.

Attachment pages can negatively affect SEO, so you may wonder: how to remove WordPress attachment pages?

Here is one important note: by removing attachment pages, we don’t actually mean to delete them once and for all. Our goal is to hide them from search engines.

So, what happens with attachment pages when we try to remove them? In this case, they redirect to the post page using 301 redirect. Again: 301 redirect for a search engine is the same as if the page has never existed.

How To Remove WordPress Attachment Pages With A Plugin

We recommend using our SEO optimization plugin Clearfy. This tool can also remove WordPress attachment pages in one click.

First of all, install the plugin on your website. Find Clearfy in the Plugin section or download it manually.

Now go to Clearfy menu.

Remove WordPress Attachment Pages And Hide Useless Webpages From Search Results

There you see the plugin settings. Go to SEO. Find Duplicate pages and activate Remove attachment pages.

Remove WordPress Attachment Pages And Hide Useless Webpages From Search Results

Once you save the changes, your post pages wouldn’t have to compete for ranking positions with attachment pages.

How To Remove WordPress Attachment Pages With Code

You can use PHP code to configure 301 redirect and prevent attachment pages from being indexed. Open functions.php and add the following piece of code before the closing “?>” tag:

add_action('template_redirect', 'template_redirect_attachment');

function template_redirect_attachment() {

global $post;

// Redirects to the post page:

if (is_attachment()) {





You should always remember the consequences of changing the code with lack of experience. Do not change anything if you are not completely sure of what you are doing and why. Otherwise, you can break the whole website. At the same time, you can avoid such problems with the plugin. The Clearfy developers regularly check its compatibility and update the plugin features. Improve your website performance easily!

Scroll to Top