wordpress recent posts show thumbnail wordpress recent posts show thumbnail wordpress wordpress

wordpress recent posts show thumbnail


You can use get_the_post_thumbnail

Usage:

<?php echo get_the_post_thumbnail( $post_id, $size, $attr ); ?>

Integrated with your code:

<?php foreach($recent_posts as $post) : ?>    <li>        <a href="<?php echo get_permalink($post['ID']) ?>">            <?php echo get_the_post_thumbnail($post['ID'], 'thumbnail'); ?>            <div><?php echo $post['post_title'] ?></div>        </a>    </li><?php endforeach; ?> 

Note: To enable Post Thumbnails, the current theme must include add_theme_support( 'post-thumbnails' ); in its functions.php file. See also Post Thumbnails.

Source(s)

Function Reference/get the post thumbnail

See also

Post Thumbnails
Function Reference/add theme support


In your current installed theme, if you are making any changes to the PHP files, it will get replaced if there are any updates done to the theme. To avoid, this, create a child theme and make updates to those php files.

Thr below blog also explains in details on how to add Thumbnail to Recent post widget.

Blog on how to Add Thumbnail to Recent posts

Hope this helps.