From e278fe3fcf262d1792a347a460bc004200a2490f Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Tue, 29 Aug 2023 22:11:22 +0000 Subject: [PATCH] Posts, Post Types: Avoid redundant SQL query in get_pages(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids an additional query by passing the query args directly to the `WP_Query::query()` method, rather than to the constructor and calling get_posts(), following [55569]. Props david.binda, azaozz, spacedmonkey, mukesh27, flixos90, SergeyBiryukov, joemcgill. Fixes #59224. git-svn-id: https://develop.svn.wordpress.org/trunk@56491 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 0bd4fc7a9f..f71a0a061d 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -6105,8 +6105,8 @@ function get_pages( $args = array() ) { */ $query_args = apply_filters( 'get_pages_query_args', $query_args, $parsed_args ); - $query = new WP_Query( $query_args ); - $pages = $query->get_posts(); + $pages = new WP_Query(); + $pages = $pages->query( $query_args ); if ( $child_of || $hierarchical ) { $pages = get_page_children( $child_of, $pages );