wp_no_robots()

In this article

This function has been deprecated. Use wp_robots_no_robots() instead on ‘wp_robots’ filter.

Display a noindex meta tag.

Description

Outputs a noindex meta tag that tells web robots not to index the page content.

Typical usage is as a ‘wp_head’ callback:

add_action( 'wp_head', 'wp_no_robots' );

Source

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";
}

Changelog

VersionDescription
5.7.0Use wp_robots_no_robots() instead on 'wp_robots' filter.
5.3.0Echo noindex,nofollow if search engine visibility is discouraged.
3.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.