How to add noindex follow automatically to archives pages in WordPress

To add the noindex, follow robots meta tag to WordPress archive pages automatically, you can use the wp_head action in your theme’s functions.php file.

Here’s an example of how you can use the wp_head action to add the noindex, follow robots meta tag to WordPress archive pages:

// Add noindex follow automatically to archives pages
// More snippets at wpunplugged.com 

add_action( 'wp_head', 'my_noindex_archives' );
function my_noindex_archives() {
  if ( is_archive() ) {
    echo '<meta name="robots" content="noindex,follow" />';
  }
}

This code will check if the current page is an archive page (e.g., a category archive, tag archive, date archive, etc.), and if it is, it will output the noindex, follow robots meta tag. This will tell search engines not to index the archive pages and to follow the links on those pages.

Note that this code will add the noindex, follow robots meta tag to all archive pages. If you only want to add the meta tag to certain types of archive pages (e.g., category archives), you can use the appropriate WordPress conditional tag in the code (e.g., is_category()).

Share this post

You might also like...

Comment

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