I am trying to create a blog-listing page, that'll display the title and the featured images. Here's the loop that I am using
page.php
<div class="p-5 container" style="text-align:center;">
<h1 style="margin-bottom:5vh;font-weight:bold;">Latest Posts</h1>
<section class="thumbnails row">
<?php $wpdb = new WP_Query(array(
'post_type'=>'post',
// 'post_type' => 'publish',
'post_status' => 'any',
'posts_per_page' => 10));
if($wpdb->have_posts()):
while($wpdb->have_posts()):
$wpdb->the_post();?>
<?php
get_template_part('blog-show');
// echo the_title();
endwhile;
endif;
?>
</section>
</div>
blog-show.php
<div class="col-12 col-sm-4">
<a href="<?php echo the_permalink() ?>">
<img src="<?php the_post_thumbnail(); ?>"
alt="<?php the_post_thumbnail_caption() ?>"/>
<h3><?php the_title(); ?></h3>
</a>
</div>
I am able to use the the_post_thumbnail
in another page but it doesn't work here.