Skip to content

Commit a844bea

Browse files
committed
Sitemaps: Render empty sitemap when URL's filtered to empty list.
Modifies the site maps to render a valid site map for each URL listed on the sitemap index page, ie `/wp-sitemap.xml`. This changes the response code for sitemaps return an empty URL list via the `wp_sitemaps_{$sitemap_type}_pre_url_list` and related filters. This ensures that all sitemap URLs submitted to search engines via the index respond with a 200 OK response. Props adrianduffell, audrasjb, cybr, devansh2002, im3dabasia1, masteradhoc, westonruter, wildworks. Fixes #61293. git-svn-id: https://develop.svn.wordpress.org/trunk@64792 602fd350-edb4-49c9-b593-d223f7449a82
1 parent c6d4745 commit a844bea

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/wp-includes/sitemaps/class-wp-sitemaps.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ public function render_sitemaps() {
204204

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

207-
// Force a 404 and bail early if no URLs are present.
208-
if ( empty( $url_list ) ) {
207+
// Force a 404 and bail early if the requested page is out of range.
208+
if ( $paged > $provider->get_max_num_pages( $object_subtype ) ) {
209209
$this->send_404();
210210
return;
211211
}

0 commit comments

Comments
 (0)