robots_txt

Filters the robots.txt output.

Description

apply_filters( 'robots_txt', (string) $output, (bool) $public ); 

Parameters (2)

0. $output (string)
Robots.txt output.
1. $public (bool)
Whether the site is considered public..

Usage

To run the hook, copy the example below.
  1. $output = apply_filters( 'robots_txt', $output, $public ); 
  2.  
  3. if ( !empty( $output ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the robots_txt callback 
  2. function filter_robots_txt( $output, $public ) { 
  3. // make filter magic happen here... 
  4. return $output
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'robots_txt', 'filter_robots_txt', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'robots_txt', 'filter_robots_txt', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/functions.php  
  1. echo apply_filters( 'robots_txt', $output, $public );