How to display recent posts in wordpress?

10:12:00 0 Comments A+ a-

Many time we need to display our recent posts. Like if you want to display recent posts at your home page or in sidebar. Any were in you website you can show latest posts with this code. This code only show 7posts in your target area. But if you want to show more or lesser then seven post then you can edit this code like showposts=7 you have to change only numerical value according to requirement. Here is the code you need to display the most recent 7 posts



Recently updated posts widget you can also use for this click below link:- https://wordpress.org/plugins/recently-updated-posts-widget Display Recently Updated Posts/Pages Sometimes we need to show most recently updated Posts/Pages in WordPress Theme. Below simple function will help you on the same.

 get_results
("SELECT ID, post_title FROM $wpdb->posts 
WHERE post_status = 'publish' AND post_modified_gmt 
< '$today' ORDER BY post_modified_gmt DESC LIMIT $howMany")):
?>

    post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID); echo "
  • "; the_title(); echo '
  • '; } ?>