Very smart WordPress meta robot tags

During WordPress install you can set WordPress to index or noindex your pages. The following code introduces more SEO friendly meta robots.

function add_metarobots()
{
  if (is_single() || is_page() ){ echo '<meta name="robots" content="index, follow" />'; }

  if (is_category() || is_archive() || is_tag()) {  echo '<meta name="robots" content="noindex, follow" />'; }

  if (is_search() || is_admin()){ echo '<meta name="robots" content="noindex, nofollow" />'; }
}

add_action('wp_head', 'add_metarobots') ;

tags: & category: -