WP_Sitemaps::render_sitemaps() WordPress Method
The WP_Sitemaps::render_sitemaps() method is used to render the sitemaps for a WordPress site. This is typically done when a user visits the WordPress admin dashboard, but it can also be done via a WordPress plugin or theme.
WP_Sitemaps::render_sitemaps() #
Renders sitemap templates based on rewrite rules.
Source
File: wp-includes/sitemaps/class-wp-sitemaps.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; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.5.0 | Introduced. |