wp_robots()
Displays the robots meta tag as necessary.
Gathers robots directives to include for the current context, using the wp_robots filter. The directives are then sanitized, and the robots meta tag is output if there is at least one relevant directive.
Hooks from the function
Return
null
. Nothing.
Usage
wp_robots();
Examples
#1 Example of adding a custom directive to the robots meta tag
This example shows how to add the directive follow
to existing robots meta tag directives.
To add your own directives, you need to use wp_robots hook. It takes an array where in the key you need to specify the name of the directive, and in the value its value.
add_filter( 'wp_robots', 'my_wp_robots_add_follow' ); function my_wp_robots_add_follow( $robots ) { $robots['follow'] = true; return $robots; }
Changelog
Since 5.7.0 | Introduced. |
Since 5.7.1 | No longer prevents specific directives to occur together. |