[wp-hackers] prevent indexing of page 2,3 and so on

Alex Hempton-Smith hempsworth at gmail.com
Fri Oct 22 06:30:42 UTC 2010


Just hook into the <head> with wp_head, and use a conditional statement in
that function:

function my_plugin_head() {
    if ( !is_home() )
        echo '<meta name="robots" content="noindex, nofollow">';
}
add_action('wp_head', 'my_plugin_head');

Untested, but should work.

-- Alex


On Fri, Oct 22, 2010 at 7:32 AM, Rich ZenMaster <richzenmaster at gmail.com>wrote:

> Do you know how to prevent indexing of pages past the home page in WP?
> I mean I don't want mysite.com/page/2, mysite.com/page/3 to be indexed.
>
> This is because I use home.php for my theme, so that page/2, page/3
> are all the same.
>
> Please give me a hint or a code snippet please, I don't want to add another
> plugin (robots meta).
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list