wp_no_robots()
Deprecated since 5.7.0. It is no longer supported and may be removed in future releases. Use
wp_robots_no_robots() on 'wp_robots' filter instead.Displays the meta tag robots noindex, which prohibits search engines from indexing the page but allows them to follow links to other pages.
Displays:
<meta name='robots' content='noindex,follow' />
Hooks into wp_head in WordPress if the current page:
- Has the GET parameter
replytocomin the url. - Is an embed page — (/function/is_embed).
- Is a registration/login page.
- Is terminated using wp_die().
- Is a preview page of the customizer.
No Hooks.
Returns
null. Nothing (null).
Usage
wp_no_robots();
Examples
#1 Prohibit indexing of tags (tag pages)
add_action( 'wp', 'set_noindex_tags' );
function set_noindex_tags() {
if ( is_tag() ) {
add_action( 'wp_head', 'wp_no_robots' );
}
}
Changelog
| Since 3.3.0 | Introduced. |
| Since 5.3.0 | Echo noindex,nofollow if search engine visibility is discouraged. |
| Deprecated since 5.7.0 | Use wp_robots_no_robots() instead on 'wp_robots' filter. |
wp_no_robots() wp no robots code WP 6.9
function wp_no_robots() {
_deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_no_robots()' );
if ( get_option( 'blog_public' ) ) {
echo "<meta name='robots' content='noindex,follow' />\n";
return;
}
echo "<meta name='robots' content='noindex,nofollow' />\n";
}