WordPress at a glance
function is not described

WP_Sitemaps::add_robots() public WP 5.5.0

Adds the sitemap index to robots.txt.

{} It's a method of the class: WP_Sitemaps{}

No Hooks.

Return

String. The robots.txt output.

Usage

$WP_Sitemaps = new WP_Sitemaps();
$WP_Sitemaps->add_robots( $output, $public );
$output(string) (required)
robots.txt output.
$public(true/false) (required)
Whether the site is public.

Changelog

Since 5.5.0 Introduced.

Code of WP_Sitemaps::add_robots() WP 5.6

<?php
public function add_robots( $output, $public ) {
	if ( $public ) {
		$output .= "\nSitemap: " . esc_url( $this->index->get_index_url() ) . "\n";
	}

	return $output;
}