GUIDE: Wordpress attachment page index

Jeepy

Elite Member
Joined
Jan 22, 2013
Messages
1,994
Reaction score
1,975
As we all know Yoast fucked up your sites a little bit by allowing to index attachment pages. As I don't use Yoast because I do not like when someone messes with my SEO, my attachment pages were indexed anyway, so then there is a permanent solution how to redirect your image attachment page to original post via 301:

1. Go to your theme files (if you have a child theme, go to that folder)
2. Create image.php file
3. Add this code:
Code:
<?php

global $post;
if ( $post && $post->post_parent ) {
    wp_redirect( esc_url( get_permalink( $post->post_parent ) ), 301 );
    exit;
} else {
    wp_redirect( esc_url( home_url( '/' ) ), 301 );
    exit;
}

4. Check your Google Webmaster indexed pages, find attachment page and check if it is redirecting correctly.
5. Wait few days or weeks so Google can remove those useless thin content pages from SERPS.

 
Also, this wil lower your bounce rate!
 
Yoast has fucked up my rankings by doing this shit too, I made some posts about it a few weeks ago. I just came across this post again when I was doing research about how to get these goddamn pages out of the SERP's.

I really don't know what that moron was thinking when he decided all images should only be able to redirect to themselves - redirecting to the parent page/post has been working fine for years and the options were more flexible before (able to add noindex to media pages alongside it). I use a plugin called SEOPress which does what it used to do without all the bullshit ass ads yoast forces down everyones neck.

I've tried to gather all the useless URLs it has generated manually from the serps and then resubmit them in webmaster tools, but it only lets me do about 10 before it gives an error. I think I will try to ping them and then as a last resort just try to submit removal requests.

For fucks sake! What is it with developers and constantly removing good features and adding new useless crap?
 
But is having having your image attachment page indexed really a bad thing? I'm seeing results where I have say 3 of the top 6 organic results for a local city search for my service. One is my landing page, the other is the attachment image page for the image included on the landing page and the other is the custom contact page the landing page points to. If you click the image attachment page, yes, the user might have a question mark going "what is this? just an image?" But my navigation bar is clear and simple to get to the service description page. If I redirect, then I'm only occupying 2 of the top 6 results.

The only legit argument (other than potential bouncing which with prominent nav may not be that big of an issue), would possibly be if your landing page isn't #1 or #2, by redirecting the image attachment page, maybe you give the landing a little more juice to rank higher?
 
Back
Top