WordPress creates dedicated page for every image attachment and it is displayed when “attachment post URL” option is selected while insert image into the post. Even when you do not select “attachment post URL” option – image attachment pages are created in WordPress website and even indexed by Google search. This can be disastrous from SEO point of view as image attachment pages only contain single image and no content.

Understanding concept: Post URL vs attachment URL

For example: you have uploaded two images: image-one.jpg and image-two.jpg in post article with URL: (basicwp.com/tips-recap/). This may result in creation of additional two image attachment page URLs as following.

Post URL: basicwp.com/tips-recap/
Image 1: basicwp.com/tips-recap/image-one/
Image 2: basicwp.com/tips-recap/image-two/

Now last two image page URLs are useless as they only show full sized images and no content. Allowing indexing of such pages is a bad SEO practise in the long run.

Ways to fix Image Attachment pages issue in WordPress

1. Preventive step – Only preventing measure you can take is to makes sure, “attachment post URL” option is NOT selected while insert images into a post. Besides this, there is no option to disable creation of dedicated image attachment pages.

2. Use Plugin – Best fix for this issue comes in the form of Attachment Pages Redirect plugin. It is a small plugin that redirects (301 permanent redirect) attachment pages to post parent automatically. If parent post is not found, then it redirects (302 temporary redirect) attachment page to the home page. Hence, basicwp.com/tips-recap/image-one/ will be redirected to basicwp.com/tips-recap/ automatically once you install this plugin. There is no setting or configuration menu for this plugin, just download, install and activate it.

3. Manual Code – If you are not fan of using plugins, then you can also implement this redirection using manual code. Open any text editor (like notepad) and paste the following code.


post_parent)); ?>

Save this file as image.php and then upload this file to your current theme folder using ftp. Now you can check if image attachment pages are being redirected to parent post page. Though this is a handy solution, use of the above plugin is recommended as it handles 301 and 302 redirects in a better manner.

7 Comments

  1. hd_online on January 22, 2013 at 2:05 pm

    Excellent Attachment plugin mate! Thanks for the info

    • Leon on May 14, 2013 at 2:18 pm

      Thanks a lot, this php code is fantastic, just I was searching for.

  2. Yalcin on February 14, 2013 at 2:14 pm

    Google has indexed nearly 200 attachment pages of my site. Each page includes only an image, no text. I want Google to deindex them all. I have uploaded and activated the plugin you mention above. All my attachment pages are now redirected to the homepage. As far as I understand this is 302 redirect.But do google deindex 302 redirected pages?

  3. PC Support Guy on February 14, 2013 at 10:00 pm

    Great article. I think i can pull this off without installing another plugin though. Thx.

  4. King on February 27, 2013 at 12:37 pm

    is there any way to remove the indexed pages from Google?

  5. Jatinder Dhiman on March 13, 2013 at 5:07 am

    Excellent Information…………. Thanks a lot

  6. habannah on February 12, 2014 at 1:53 pm

    Quote: “1. Preventive step – Only preventing measure you can take is to makes sure, “attachment post URL” option is NOT selected while insert images into a post. Besides this, there is no option to disable creation of dedicated image attachment pages.”

    That’s incorrect. Attachment pages are created no matter what. There is no preventative measure possible…

Leave a Comment