wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



get_sitemap_url › WordPress Function

Seit5.5.1
Veraltetn/v
get_sitemap_url ( $name, $subtype_name = '', $page = 1 )
Parameter: (3)
  • (string) $name The sitemap name.
    Erforderlich: Ja
  • (string) $subtype_name The sitemap subtype name. Default empty string.
    Erforderlich: Nein
    Standard: (leer)
  • (int) $page The page of the sitemap. Default 1.
    Erforderlich: Nein
    Standard: 1
Gibt zurück:
  • (string|false) The sitemap URL or false if the sitemap doesn't exist.
Definiert in:
Codex:

Retrieves the full URL for a sitemap.



Quellcode

function get_sitemap_url( $name, $subtype_name = '', $page = 1 ) {
	$sitemaps = wp_sitemaps_get_server();

	if ( ! $sitemaps ) {
		return false;
	}

	if ( 'index' === $name ) {
		return $sitemaps->index->get_index_url();
	}

	$provider = $sitemaps->registry->get_provider( $name );
	if ( ! $provider ) {
		return false;
	}

	if ( $subtype_name && ! in_array( $subtype_name, array_keys( $provider->get_object_subtypes() ), true ) ) {
		return false;
	}

	$page = absint( $page );
	if ( 0 >= $page ) {
		$page = 1;
	}

	return $provider->get_sitemap_url( $subtype_name, $page );
}