Filter hook 'wp_robots'

in WP Core File wp-includes/robots-template.php at line 32

View Source

wp_robots

Filter Hook
Description
Filters the directives to be included in the 'robots' meta tag. The meta tag will only be included as necessary.

Hook Information

File Location wp-includes/robots-template.php View on GitHub
Hook Type Filter
Line Number 32

Hook Parameters

Type Name Description
array $robots 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.

Usage Examples

Basic Usage
<?php
// Hook into wp_robots
add_filter('wp_robots', 'my_custom_filter', 10, 1);

function my_custom_filter($robots) {
    // Your custom filtering logic here
    return $robots;
}

Source Code Context

wp-includes/robots-template.php:32 - How this hook is used in WordPress core
<?php
  27  	 *
  28  	 * @param array $robots Associative array of directives. Every key must be the name of the directive, and the
  29  	 *                      corresponding value must either be a string to provide as value for the directive or a
  30  	 *                      boolean `true` if it is a boolean directive, i.e. without a value.
  31  	 */
  32  	$robots = apply_filters( 'wp_robots', array() );
  33  
  34  	$robots_strings = array();
  35  	foreach ( $robots as $directive => $value ) {
  36  		if ( is_string( $value ) ) {
  37  			// If a string value, include it as value for the directive.

PHP Documentation

<?php
/**
	 * Filters the directives to be included in the 'robots' meta tag.
	 *
	 * The meta tag will only be included as necessary.
	 *
	 * @since 5.7.0
	 *
	 * @param array $robots 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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/robots-template.php
Related Hooks

Related hooks will be displayed here in future updates.