Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

Displaying Recent Post in WordPress with small thumbnails

Displaying Recent Post in WordPress with small thumbnails

In this post I am going to show you how to display recent post with small thumbnails, I have used this code in one of my client’s website in footer region. First thing is to add support to your theme For feature image.

WordPress custom theme Featured image support

First open your theme’s  function.php and paste code below :

add_theme_support( 'post-thumbnails' );
add_image_size( 'footer-thumb', 64, 64, false );

You can change 64,64 to your own suppose you want to show image with resolution 120*100 then use add_image_size( 'footer-thumb', 120, 100, false );

Now we are going to create a php code to display images .

<h2>Recent Post</h2>
<?php
$args = array( 'numberposts' => '4' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo get_the_post_thumbnail($recent["ID"], 'footer-thumb');
echo '&nbsp;&nbsp;<a href="'.get_permalink($recent["ID"]). '" style="color:#ffffff">' .$recent["post_title"].'</a> ';
}
?>

Paste above this code area where you want to show recent post.

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments