From 65a6412681f2fe1d36be54b4e9ad3f96a59a24cb Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Jul 2020 12:01:46 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@48282 602fd350-edb4-49c9-b593-d223f7449a82 --- .../sitemaps/providers/class-wp-sitemaps-posts.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php b/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php index 54e83e913b..3ec20bf23f 100644 --- a/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php +++ b/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php @@ -92,13 +92,6 @@ class WP_Sitemaps_Posts extends WP_Sitemaps_Provider { $query = new WP_Query( $args ); - /** - * Returns an array of posts. - * - * @var array $posts - */ - $posts = $query->get_posts(); - $url_list = array(); /* @@ -122,7 +115,7 @@ class WP_Sitemaps_Posts extends WP_Sitemaps_Provider { $url_list[] = $sitemap_entry; } - foreach ( $posts as $post ) { + foreach ( $query->posts as $post ) { $sitemap_entry = array( 'loc' => get_permalink( $post ), );