Query: Improved sticky post query

Ensure that the parameters `update_post_meta_cache`, `update_post_term_cache`, `cache_results`, `suppress_filters` and 
`lazy_load_term_meta` that are passed to WP_Query, are also passed down to the secondary query used to get sticky 
posts. 

Props Spacedmonkey, peterwilsoncc, rehanali, uday17035. 
Fixes #36907.


Built from https://develop.svn.wordpress.org/trunk@52982


git-svn-id: http://core.svn.wordpress.org/trunk@52571 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
spacedmonkey 2022-03-23 10:39:06 +00:00
parent dcd54244a6
commit e8bf92cf76
2 changed files with 9 additions and 5 deletions

View File

@ -3260,10 +3260,14 @@ class WP_Query {
if ( ! empty( $sticky_posts ) ) { if ( ! empty( $sticky_posts ) ) {
$stickies = get_posts( $stickies = get_posts(
array( array(
'cache_results' => $q['cache_results'],
'lazy_load_term_meta' => $q['lazy_load_term_meta'],
'post__in' => $sticky_posts, 'post__in' => $sticky_posts,
'post_type' => $post_type, 'post_type' => $post_type,
'post_status' => 'publish', 'post_status' => 'publish',
'nopaging' => true, 'suppress_filters' => $q['suppress_filters'],
'update_post_meta_cache' => $q['update_post_meta_cache'],
'update_post_term_cache' => $q['update_post_term_cache'],
) )
); );

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.0-alpha-52981'; $wp_version = '6.0-alpha-52982';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.