I was wondering if anyone new how to show the 3 most recent posts in Wordpress? Any help would be much appreciated.
How about just the post's thumbnail outputting 3 times?
WordPress have an inbuilt function to get the recent posts.
wp_get_recent_posts( $args ) ;
$args
is the arguments you need to pass. To get the three most recent published posts you can do it like :
$args = array('numberposts' => 3, 'post_status' => 'publish');
$recent_posts = wp_get_recent_posts( $args ) ;
print_r($recent_posts);
You can get more info on this link wp_get_recent_posts
Hope this helps you :)
You can use query_posts
For example, on the homepage, you would normally see the latest 10 posts. If you want to show only 3 posts (and don't care about pagination), you can use query_posts() like so:
query_posts( 'posts_per_page=3' );
Hope this help!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.