Make WordPress Core

Ticket #50571: 0001-Fix-50571-List-homepage-when-site-contains-no-pages.patch

File 0001-Fix-50571-List-homepage-when-site-contains-no-pages.patch, 939 bytes (added by pacifika, 4 years ago)

Minimum 1 sitemap for pages.

  • inc/providers/class-wp-sitemaps-posts.php

    From 0f458c21800c82d1a52897aeada8d35f7d58a03a Mon Sep 17 00:00:00 2001
    From: Sander van Dragt <sander@vandragt.com>
    Date: Tue, 7 Jul 2020 15:58:15 +0100
    Subject: [PATCH] Fix #50571 List homepage when site contains no pages.
    
    ---
     inc/providers/class-wp-sitemaps-posts.php | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/inc/providers/class-wp-sitemaps-posts.php b/inc/providers/class-wp-sitemaps-posts.php
    index 7e89de1..d116466 100644
    a b class WP_Sitemaps_Posts extends WP_Sitemaps_Provider { 
    178178                $args['no_found_rows'] = false;
    179179
    180180                $query = new WP_Query( $args );
    181 
    182                 return isset( $query->max_num_pages ) ? $query->max_num_pages : 1;
     181                $min_num_pages = (int)($post_type === 'page');
     182                return isset( $query->max_num_pages ) ? max($min_num_pages,$query->max_num_pages) : 1;
    183183        }
    184184
    185185        /**