WordPress at a glance
function is not described

WP_Sitemaps::render_sitemaps() public WP 5.5.0

Renders sitemap templates based on rewrite rules.

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

No Hooks.

Return

Null. Nothing.

Usage

$WP_Sitemaps = new WP_Sitemaps();
$WP_Sitemaps->render_sitemaps();

Notes

  • Global. WP_Query. $wp_query WordPress Query object.

Changelog

Since 5.5.0 Introduced.

Code of WP_Sitemaps::render_sitemaps() WP 5.5.1

<?php
public function render_sitemaps() {
	global $wp_query;

	$sitemap         = sanitize_text_field( get_query_var( 'sitemap' ) );
	$object_subtype  = sanitize_text_field( get_query_var( 'sitemap-subtype' ) );
	$stylesheet_type = sanitize_text_field( get_query_var( 'sitemap-stylesheet' ) );
	$paged           = absint( get_query_var( 'paged' ) );

	// Bail early if this isn't a sitemap or stylesheet route.
	if ( ! ( $sitemap || $stylesheet_type ) ) {
		return;
	}

	if ( ! $this->sitemaps_enabled() ) {
		$wp_query->set_404();
		status_header( 404 );
		return;
	}

	// Render stylesheet if this is stylesheet route.
	if ( $stylesheet_type ) {
		$stylesheet = new WP_Sitemaps_Stylesheet();

		$stylesheet->render_stylesheet( $stylesheet_type );
		exit;
	}

	// Render the index.
	if ( 'index' === $sitemap ) {
		$sitemap_list = $this->index->get_sitemap_list();

		$this->renderer->render_index( $sitemap_list );
		exit;
	}

	$provider = $this->registry->get_provider( $sitemap );

	if ( ! $provider ) {
		return;
	}

	if ( empty( $paged ) ) {
		$paged = 1;
	}

	$url_list = $provider->get_url_list( $paged, $object_subtype );

	// Force a 404 and bail early if no URLs are present.
	if ( empty( $url_list ) ) {
		$wp_query->set_404();
		status_header( 404 );
		return;
	}

	$this->renderer->render_sitemap( $url_list );
	exit;
}