Make WordPress Core


Ignore:
Timestamp:
07/03/2020 12:01:46 PM (4 years ago)
Author:
swissspidy
Message:

Sitemaps: Do not unnecessarily call WP_Query::get_posts() in posts provider.

The posts have already been fetched at this point, no need to do it again.

Props Chouby.
Fixes #50463.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php

    r48104 r48282  
    9393        $query = new WP_Query( $args );
    9494
    95         /**
    96          * Returns an array of posts.
    97          *
    98          * @var array<int, \WP_Post> $posts
    99          */
    100         $posts = $query->get_posts();
    101 
    10295        $url_list = array();
    10396
     
    123116        }
    124117
    125         foreach ( $posts as $post ) {
     118        foreach ( $query->posts as $post ) {
    126119            $sitemap_entry = array(
    127120                'loc' => get_permalink( $post ),
Note: See TracChangeset for help on using the changeset viewer.