robots_txt
Filters the robots.txt output.
Usage
add_filter( 'robots_txt', 'wp_kama_robots_txt_filter', 10, 2 ); /** * Function for `robots_txt` filter-hook. * * @param string $output The robots.txt output. * @param bool $public Whether the site is considered "public". * * @return string */ function wp_kama_robots_txt_filter( $output, $public ){ // filter... return $output; }
- $output(string)
- The robots.txt output.
- $public(true|false)
- Whether the site is considered "public".
Changelog
Since 3.0.0 | Introduced. |
Where the hook is called
robots_txt
wp-includes/functions.php 1727
echo apply_filters( 'robots_txt', $output, $public );
Where the hook is used in WordPress
wp-includes/sitemaps/class-wp-sitemaps.php 79
add_filter( 'robots_txt', array( $this, 'add_robots' ), 0, 2 );