Filters the directives to be included in the ‘robots’ meta tag.
Description
The meta tag will only be included as necessary.
Parameters
$robots
array- Associative array of directives. Every key must be the name of the directive, and the corresponding value must either be a string to provide as value for the directive or a boolean
true
if it is a boolean directive, i.e. without a value.
Source
$robots = apply_filters( 'wp_robots', array() );
Changelog
Version | Description |
---|---|
5.7.0 | Introduced. |
Example of adding a noindex robots tag.
To affect pages with a certain page template, you can add this directly to the template, as long as it’s above the call to
wp_header()
.To have more granular control over what pages are affected, you can add the snippet to your functions.php file and work with the current page inside the function: