Title: wp_robots_noindex
Published: March 9, 2021
Last modified: August 20, 2026

---

# wp_robots_noindex( array $robots ): array

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#changelog)

Adds `noindex` to the robots meta tag if required by the site configuration.

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

If a blog is marked as not being public then noindex will be output to tell web 
robots not to index the page content. Add this to the [‘wp_robots’](https://developer.wordpress.org/reference/hooks/wp_robots/)
filter.

Typical usage is as a [‘wp_robots’](https://developer.wordpress.org/reference/hooks/wp_robots/)
callback:

    ```php
    add_filter( 'wp_robots', 'wp_robots_noindex' );
    ```

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#see-also)󠁿

 * [wp_robots_no_robots()](https://developer.wordpress.org/reference/functions/wp_robots_no_robots/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#parameters)󠁿

 `$robots`arrayrequired

Associative array of robots directives.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#return)󠁿

 array Filtered robots directives.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_robots_noindex/?output_format=md#source)󠁿

    ```php
    function wp_robots_noindex( array $robots ) {
    	if ( ! get_option( 'blog_public' ) ) {
    		return wp_robots_no_robots( $robots );
    	}

    	return $robots;
    }
    ```

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

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

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

Adds `noindex` to the robots meta tag.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

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

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

## User Contributed Notes

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