DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Duplicate content is often a problem with WordPress blog, and as you probably know it, it can hurt your blog SEO. Here is a small code to insert on your header.php file, to get rid of duplicate content in your WordPress blog.

Simply paste theses line between the <head> and </head> tags in your header.php file.

<?php if((is_home() && ($paged < 2 )) || is_single() || is_page() || is_category()){
    echo '<meta name="robots" content="index,follow" />';
} else {
    echo '<meta name="robots" content="noindex,follow" />';

By using WordPress conditionnal tags, this code ensure that your homepage, posts, pages and category pages are indexed by search engines spiders, but prevent all other pages (feeds, archives, etc) from being indexed and create involuntary duplicate content.


  1. first i wanna say thank u so much for this article.
    second, you miss “?>” at the end of code.
    {sorry if my english is bad, i can’t speak much english]

  2. Hi,

    I was just wondering. If i have custom post types on my blog and i use this piece of code will search engines be able to index those customer post types?

    I would really appriciate an email if you know the answer.

    Thanks for the great blog. i have found it very useful over the past months.


  3. I am just fed up of duplicate comment issue and from long time i was searching for any useful tips to get rid of it but didn’t. Thanks to you for sharing this valuable piece of information.

  4. Hi,

    Can you please explain the meaning of $paged?
    I assume it is a variable but I can not relate it to wordpress as I have looked in header.php and no such variable exists there.

    Great site!

  5. Ok, here is one answer:

    $paged is a global var that is set to the page number WP is displaying.

Leave a Comment

Your email address will not be published. Required fields are marked *