Sitemaps: Ensure entry for ‘page’ post type sitemap in index.

If there are no pages and no static homepage, there will still be one sitemap including the homepage URL.

This change ensures that this sitemap is correctly listed in the sitemap index.

Props Chouby, pacifika, elrae.
Fixes #50571.
Built from https://develop.svn.wordpress.org/trunk@48476


git-svn-id: http://core.svn.wordpress.org/trunk@48245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2020-07-14 12:26:02 +00:00
parent 5eb3f0ffcb
commit 2c92383b8d
2 changed files with 3 additions and 2 deletions

View File

@ -174,7 +174,8 @@ class WP_Sitemaps_Posts extends WP_Sitemaps_Provider {
$query = new WP_Query( $args );
return isset( $query->max_num_pages ) ? $query->max_num_pages : 1;
$min_num_pages = ( 'page' === $post_type && 'posts' === get_option( 'show_on_front' ) ) ? 1 : 0;
return isset( $query->max_num_pages ) ? max( $min_num_pages, $query->max_num_pages ) : 1;
}
/**

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-beta1-48475';
$wp_version = '5.5-beta1-48476';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.