Disable image attachment page URLs in WordPressUpdated On May 23, 2015 October 11, 2012 -Written By
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.
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.
Excellent Attachment plugin mate! Thanks for the info
Thanks a lot, this php code is fantastic, just I was searching for.
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?
Great article. I think i can pull this off without installing another plugin though. Thx.
is there any way to remove the indexed pages from Google?
Excellent Information…………. Thanks a lot
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…