WP_Sitemaps_Provider::get_sitemap_url( string $name, int $page )

Gets the URL of a sitemap entry.

Parameters

$name

(string) (Required) The name of the sitemap.

$page

(int) (Required) The page of the sitemap.

Return

(string) The composed URL for a sitemap entry.

Source

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

public function get_sitemap_url( $name, $page ) {
		global $wp_rewrite;

		// Accounts for cases where name is not included, ex: sitemaps-users-1.xml.
		$params = array_filter(
			array(
				'sitemap'         => $this->name,
				'sitemap-subtype' => $name,
				'paged'           => $page,
			)
		);

		$basename = sprintf(
			'/wp-sitemap-%1$s.xml',
			implode( '-', $params )
		);

		if ( ! $wp_rewrite->using_permalinks() ) {
			$basename = '/?' . http_build_query( $params, null, '&' );
		}

		return home_url( $basename );
	}

Changelog

Version Description
5.5.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_sitemaps_provider/get_sitemap_url