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.



git-svn-id: https://develop.svn.wordpress.org/trunk@52982 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonny Harris
2022-03-23 10:37:11 +00:00
parent d7f9f4405b
commit b3d6638139
2 changed files with 30 additions and 4 deletions

View File

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