| @@ -3814,30 +3814,12 @@ | ||
| 3814 | 3814 | $buffer = []; |
| 3815 | 3815 | } |
| 3816 | 3816 | } |
| 3817 | 3817 | |
| 3818 | - // Flush the trailing partial page. | |
| 3819 | - // | |
| 3820 | - // A type that produced nothing writes no page at all in index | |
| 3821 | - // mode (#836). It used to write one empty urlset and list it in | |
| 3822 | - // the index, so a crawler was asked to fetch a file that | |
| 3823 | - // answers with no URLs — Search Console reports an empty | |
| 3824 | - // sitemap referenced from an index as a warning, and the fetch | |
| 3825 | - // is wasted on every pass. On this site three of eleven | |
| 3826 | - // children were empty: a post type with nothing published and | |
| 3827 | - // two taxonomies with no terms. | |
| 3828 | - // | |
| 3829 | - // Single-file mode still writes its one page even when empty, | |
| 3830 | - // because that file IS the site's /sitemap.xml and a 404 there | |
| 3831 | - // is worse than an empty urlset. Nothing lists it, so it costs | |
| 3832 | - // no crawl budget. | |
| 3833 | - // | |
| 3834 | - // Skipping the write also keeps the filename out of | |
| 3835 | - // $results['sitemaps_generated'], which is what | |
| 3836 | - // prune_orphaned_segments() treats as "written this run" — so | |
| 3837 | - // a type that empties after previously publishing has its | |
| 3838 | - // stale file deleted rather than left serving. | |
| 3839 | - if (!empty($buffer) || ($page === 0 && $index_config === null)) { | |
| 3818 | + // Flush the trailing partial page, or a single empty page when the | |
| 3819 | + // type had no entries at all (parity with the previous behavior of | |
| 3820 | + // always writing at least one page per configured child). | |
| 3821 | + if (!empty($buffer) || $page === 0) { | |
| 3840 | 3822 | $page++; |
| 3841 | 3823 | $this->write_sitemap_page($this->paginate_url($sitemap_config['url'], $page), $this->wrap_urlset($buffer, $settings, $image_ns), $type, count($buffer), $results, $index_children); |
| 3842 | 3824 | } |
| 3843 | 3825 | |