Title: wp_robots
Published: March 9, 2021
Last modified: February 24, 2026

---

# apply_filters( ‘wp_robots’, array $robots )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#wp--skip-link--target)

Filters the directives to be included in the ‘robots’ meta tag.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#description)󠁿

The meta tag will only be included as necessary.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#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](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#source)󠁿

    ```php
    $robots = apply_filters( 'wp_robots', array() );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/robots-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/robots-template.php#L32)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/robots-template.php#L32-L32)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_robots()](https://developer.wordpress.org/reference/functions/wp_robots/)`wp-includes/robots-template.php` |

Displays the robots meta tag as necessary.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.7.0](https://developer.wordpress.org/reference/since/5.7.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/wp_robots/?output_format=md#comment-content-4953)
 2.    [jakeparis](https://profiles.wordpress.org/jakeparis/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/wp_robots/#comment-4953)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_robots%2F%23comment-4953)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_robots%2F%23comment-4953)
 4.  Example of adding a noindex robots tag.
 5.      ```php
         add_filter( 'wp_robots', function( $robots ) {
         	$robots['noindex'] = true;
     
         	return $robots;
         } );
         ```
     
 6.  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()`.
 7.  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:
 8.      ```php
         add_filter( 'wp_robots', function( $robots ) {
         	$id = get_the_ID();
     
         	if ( 19 === $id ) {
         		$robots['noindex'] = true;
         	}
     
         	return $robots;
         } );
         ```
     
 9.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_robots%2F%3Freplytocom%3D4953%23feedback-editor-4953)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_robots%2F)
before being able to contribute a note or feedback.