WP_Sitemaps::add_robots() WordPress Method

The WP_Sitemaps::add_robots() method allows you to add a sitemap to your robots.txt file. This is useful if you want your sitemap to be indexed by search engines.

WP_Sitemaps::add_robots( string $output, bool $public ) #

Adds the sitemap index to robots.txt.


Parameters

$output

(string)(Required)robots.txt output.

$public

(bool)(Required)Whether the site is public.


Top ↑

Return

(string) The robots.txt output.


Top ↑

Source

File: wp-includes/sitemaps/class-wp-sitemaps.php

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

		return $output;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.