get_the_post_thumbnail() – Invalid argument supplied for foreach() in /wp-includes/post-thumbnail-template.php on line 64

This Trac ticket here describes your problem and the cause:

https://core.trac.wordpress.org/ticket/26321

I got a warning/error related to update_post_thumbnail_cache()
function:

Warning: Invalid argument supplied for foreach() in ./wp-includes/post-thumbnail-template.php on line 64
The $wp_query->posts array is missing, but we have the single
$wp_query->post.

foreach ( $wp_query->posts as $post ) {
  if ( $id = get_post_thumbnail_id( $post->ID ) )
      $thumb_ids[] = $id;
}

Ticket #26321 describes that when a custom WP_Query loop on a page tries to grab a post thumbnail, Core tries to cache the thumbnails of the posts in the current query.

The problem happens because when doing so it loops over the posts in the query, but it never checks if the array of posts is empty or not. If it is, then you get the warning.

For the moment I would wait for a resolution in WP Core. The warning isn’t breaking anything in your codes logic ( though a warning is still, undesirable ).

You can help though, log in to trac, download the patches and help test them. The more testing and help you can provide, the faster the bug can be fixed and the sooner it can get into WordPress Core.

If you manage to fix the bug yourself and satisfy all the unit tests, you might get props! Your name would be on the about/contributors page in every WordPress install running that release