Make WordPress Core

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

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

Formatted version of the previous attachment.

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

    From f0cb3aa2ccc7f58572617f3e7c7dddea7ca379c3 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..2a8a83b 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        /**