Skip to content

Commit

Permalink
fix: ensure query has posts before accessing the first one [closes #632]
Browse files Browse the repository at this point in the history
  • Loading branch information
abaicus committed Aug 9, 2023
1 parent 1d34e9b commit 4264b4e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion inc/hero_preloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function add_preload_to_image_attributes( $attr, $attachment ) {

if ( is_singular() && $queried_post instanceof WP_Post ) {
$post = $queried_post;
} elseif ( $wp_query->is_main_query() && isset( $wp_query->posts[0] ) ) {
} elseif ( $wp_query->is_main_query() && $wp_query->post_count > 0 && isset( $wp_query->posts[0] ) ) {
$post = $wp_query->posts[0];
}

Expand Down

0 comments on commit 4264b4e

Please sign in to comment.