How to Improve SEO by NoIndexing Attachment and Pagination in WordPress?


The wordpress does not automatically add INDEX or NOINDEX meta within the HTML head tag. Some images (or other attachments) they do have their own pages, but these should not be indexed by Google as the Google Page Rank will be treating these as duplicates. Similarly, the pagination pages such as is_search, is_tag, is_category(), is_archive() should be removed from the index pages.

To do this, open the header.php template in your child theme and insert the following php code within the HEAD tag.

1
2
3
4
5
6
7
<php
if (is_paged() || is_search() || is_404() || is_archive() || is_category() || is_tag() || is_attachment()) { 
    echo '<meta name="robots" content="noindex,follow" />'; 
} else {
    echo '<meta name="robots" content="index,follow" />';
}
?>
<php
if (is_paged() || is_search() || is_404() || is_archive() || is_category() || is_tag() || is_attachment()) { 
    echo '<meta name="robots" content="noindex,follow" />'; 
} else {
    echo '<meta name="robots" content="index,follow" />';
}
?>

is_404() is also checked for those pages that return “404 NOT Found”. After duplication removed, the search engines only indexes content-wise pages so that your SEO will definitly improve.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
231 words
Last Post: C++ Coding Exercise: How to Check if a Large Integer is divisible by 11?
Next Post: How to Add Adsense Ads to bbPress Forum?

The Permanent URL is: How to Improve SEO by NoIndexing Attachment and Pagination in WordPress?

Leave a Reply