Posts, Post types: Prevent get_page_by_title() parsing query twice.

In `get_page_by_title()` access the populated `WP_Query::posts` property directly rather than via the `WP_Query::get_posts()` method. This removes unnecessary reprocessing of the query.

Follow up to [54234].

Props david.binda, mukesh27, spacedmonkey.
Fixes #56721.



git-svn-id: https://develop.svn.wordpress.org/trunk@54377 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson
2022-10-04 03:31:04 +00:00
parent c87b90fa7b
commit 4a9ab59d91
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -5787,7 +5787,7 @@ function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' )
'order' => 'ASC',
);
$query = new WP_Query( $args );
$pages = $query->get_posts();
$pages = $query->posts;
if ( empty( $pages ) ) {
return null;