Naturally, when one attaches images to WordPress pages or posts, these images are duplicated into their very own webpages; These automatically created attachment pages can then be indexed via search engines like Google, and then mislead people to visit them, instead to their ancestor page that is text based.

How can one prevent this problem from ahead when creating a brand new site? What should be changed in the settings to make sure that this phenomenon won't happen / No image page will be created when images are attached to pages posts?


I would prefer a way without using 301 redirects, but such desire might be problematic as the WordPress source code would be updated each time anew, and the customization that prevents the formation of attachment-pages will be deleted.

1 Answer 1


Attachment posts aren't exactly the worst thing in the world. They increase the size of your site, and can contain relevant data if you're using alt, description and title tags. HOWEVER, I do completely see your point, but the good news is that Google won't crawl those pages if they're not linked anywhere or included in your XML sitemap.

Here's a WP Beginner's tutorial from a few years ago. I'm a little reluctant to send you there because it references kind of old plugins, but the one note they make is to auto-forward all attempts at accessing your attachment posts by putting

<?php wp_redirect(get_permalink($post->post_parent)); ?>

in your first line of image.php for images specifically, or, I think what might be more global would be attachment.php.

Also, I just checked if the Attachment Pages Redirect plugin they reference is still being kept up, and, as of 4 weeks ago, it is, so that's another alternative.

Otherwise, I'd be on the side of leaving it alone, it's turned on by default for a reason. Mind you, that could change, but the few articles I've read say that there is the chance that keeping them open increases your SEO (but who really knows).

Anyway, good luck!

  • The site contains relatively small number of Pages... I want Googlers to reach the site only from textual based content, and not from image-posts... I am not sure yet if I'm gonna use a sitemap, therefore, it is very important for me to totally disable this image-post functionality, better without any plugins...
    – user87795
    Dec 5, 2016 at 8:16
  • I would recommend generating a sitemap, because that way it gives the search bots a list of what to crawl, instead of doing it through your HTML navigation. And that way you can be specific in what you do and do not want to be indexed by Google.
    – socki03
    Dec 5, 2016 at 13:52
  • I know the concept of XML sitemaps but I need a way to disable the creation of these from the start, to not ever deal with them in the future. To lower the chance to basically zero to ever handle these (for example, if I deleted the sitemap module)...
    – user87795
    Dec 5, 2016 at 13:56

Your Answer

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