Skip to content

Commit 6856026

Browse files
Further optimize WP_Query
Co-authored-by: swissspidy <[email protected]>
1 parent f74f4f4 commit 6856026

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

plugins/image-prioritizer/helper.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,13 @@ static function ( $host ) {
170170
// Obtain the host of an image attachment's URL in case a CDN is pointing all images to an origin other than the home or site URLs.
171171
$image_attachment_query = new WP_Query(
172172
array(
173-
'post_type' => 'attachment',
174-
'post_mime_type' => 'image',
175-
'post_status' => 'inherit',
176-
'posts_per_page' => 1,
177-
'fields' => 'ids',
173+
'post_type' => 'attachment',
174+
'post_mime_type' => 'image',
175+
'post_status' => 'inherit',
176+
'posts_per_page' => 1,
177+
'fields' => 'ids',
178+
'no_found_rows' => true,
179+
'update_post_term_cache' => false, // Note that update_post_meta_cache is not included as well because wp_get_attachment_image_src() needs postmeta.
178180
)
179181
);
180182
if ( isset( $image_attachment_query->posts[0] ) && is_int( $image_attachment_query->posts[0] ) ) {

0 commit comments

Comments
 (0)