Exclude WordPress Posts Without an Image on WP Query

Query Post Only with Featured Image and Exclude all the Rest Before Going into the Loop.

I was struggling to find a way how to exclude posts that did not have images because I wanted only featured images post on my home page so I found a good article online that gave some good information on how to perform the task.

$args = array( 'meta_key' => '_thumbnail_id' );
$query = new WP_Query( $args );