How to Display Recent Posts with Thumbnails in WordPress

Okay, lets get started. Open functions.php (or create it in case you dont have one but I doubt it). To make use of the thumbnails, firstly we need to activate them using the next piece of code:

let`s write the function, inside the same functions.php file.

function delicious_recent_posts() {
    $del_recent_posts = new WP_Query();
        while ($del_recent_posts->have_posts()) : $del_recent_posts->the_post(); ?>
                <a href="<?php esc_url(the_permalink()); ?>">
                    <?php the_post_thumbnail('delicious-recent-thumbnails'); ?>
                    <a href="<?php esc_url(the_permalink()); ?>">
                        <?php esc_html(the_title()); ?>
        <?php endwhile;

The code is easy to understand. We assigned a new wp query to the $del_recent_posts variable which acts exactly like a WordPress loop, but for the things we asked it to use (showposts=3). So, as long as the query finds posts, generates a list of items which displays the latest 3 posts with thumbnail() and title().

The piece of code is written in a minimal manner, but you can add HTML markup like divs with classes to style the widget in your own way.

In order to make it work, you have to call the function anywhere in your WordPress theme (single.phpfooter.phpsidebar.php, etc), with the next line of code. Most people are using it inside the sidebar.

<?php echo delicious_recent_posts(); ?>
<?php echo delicious_recent_posts('showposts=3'); ?>

That should be all. This is how you could showcase your recent posts with thumbnails, without using a plugin. in Delhi NCR, in Laxmi nagar, in Ganesh nagar, in shakarpur, in Ramesh park, in Nirman Vihar, in Geeta colony, in Mandawali, in west vinod nagar, in karkardooma, in Preet vihar, in Shadipur, in Rajouri garden, in Bara khamba, in yamuna bank, in joshi colony, in Chandar vihar, in Manglam School, in Madhu vihar, in Mayur vihar, in Alla colony, in Dwarka, in Noida, in Greater Noida