WordPress Image Attachment Pages Indexed by Google

WordPress Image Attachment Pages Indexed by Google. I have to admit, this is a bit off topic, but nonetheless a big nuisance for those who bump into this problem. Like I just did.
Each time we insert an image or gallery, a page is created which results in countless pages without content getting indexed by Google. If a human can access those pages so can Google.
Media Attachments are in fact a post type, so they will always have a URL assigned , in the same way that posts have.
You will end-up having something like this :

yoursite.com/testpost (your actual post)
yoursite.com/testpost/imagename1/ (url 2)
yoursite.com/testpost/imagename2/ (url 3)

As many images you insert as many urls you are going to create.
This is quite disastrous if it happens so, for your WordPress Seo, because you will get a lot of no content duplicates.
So what is to do ?
I'll introduce first the easiest solution to you torment :)
Simply install this plugin : http://wordpress.org/extend/plugins/attachment-pages-redirect/
As its name is saying it redirects the attachment pages to the post parent, if there is any. Otherwise it will redirect them to the home page.
This is the fastest and the easiest way.
If you are against many plugins like I'm you can do this manually.
Add to your theme's functions.php the following code:

 

add_action( 'template_redirect', 'attachment_redirect', 1 );
/**
* Redirect any attachment page to their parent with 301 redirection
*/
function attachment_redirect() {
global $post;
if ( is_attachment() AND isset( $post->post_parent) AND is_numeric( $post->post_parent ) ) {
wp_redirect( get_permalink( $post->post_parent ), 301 );
exit();
}
}

Be careful, in both cases, no matter which method you might use, is necessary to remove the indexed attachments pages.
That's easy to do.

Wordpress Image Attachment Pages Indexed by Google

WordPress Image Attachment Pages Indexed by Google

Just login into your Google Webmaster account (create one if you don't already have one) and go to your site, scroll down to "Optimization" and navigate to "Remove URLs".

Wordpress Image Attachment Pages Indexed by Google - Remove URL

WordPress Image Attachment Pages Indexed by Google - Remove URL

Create a new removal request and you've bypassed with great success the this issue:
Wordpress Image Attachment Pages Indexed by Google.

Sign-up for the Latest Posts

Get fresh content from Cmonppl.com

Bogdan About Bogdan

Comments

  1. Sunu Philip says:

    I am having this problem... images getting their own attachment pages...and Google indexing them all. Oh what a mess. Thank you for your insights. I will be going for the second method as I have already some plugins installed.

  2. Hi,
    Thanks for your share.Its great to know about it.

  3. Ghanasyam says:

    Thanks a lot. This article was very informative for a beginner like me.

Speak Your Mind

*

CommentLuv badge