NoFollow Entire Website

Thought this was a great question so I went digging. In default-filters.php on line 208 there’s add_action('wp_head', 'noindex', 1); as of WordPress 4.1. The noindex() function in turn checks to see if you have set blog_public option to 0. If you have, it calls wp_no_robots() which is simply:

function wp_no_robots() {
    echo "<meta name="robots" content="noindex,follow" />\n";
}

Neither of last methods are filterable, but a simple plugin will do the trick to remove the hook:

/*
 * Declare plugin stuff here
 */

remove_action('wp_head','noindex',1);

Now, you’re free to hook your own action on to echo out what you want.

add_action('wp_head', 'my_no_follow', 1);

function my_no_follow() {
    if ( '0' == get_option('blog_public') ) {
        echo "<meta name="robots" content="noindex,nofollow" />\n";
    }
}

Leave a Comment