You won’t get anything back from your template simply because the loop returns what is in the main query object for that specific page. To see what is actually in the main query object, you should do var_dump( $wp_query );
outside the loop.
To display custom content on a page template, you will need to run a custom query to pull in the required posts. pre_get_posts
does not work on page templates, so you will need WP_Query
or get_posts
to run a custom query
EXAMPLE:
$args = [
'posts_per_page' => 6,
// Add any extra query parameters here according to https://codex.wordpress.org/Class_Reference/WP_Query
];
$q = new WP_Query( $args );
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post();
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
}
wp_reset_postdata();
}