wppaste
WordPress

WP_Sitemaps::render_sitemaps()

Since
5.5.0
Source
wp-includes/sitemaps/class-wp-sitemaps.php:163
Renders sitemap templates based on rewrite rules.

Uses · 6

Source

	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;	}

History

Introduced in 5.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/sitemaps/class-wp-sitemaps.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.