WordPress Recent posts without plugin
Following code is used to display most recent posts. We can limit number of posts displayed by specifying number of posts we want to display.
<ul> <li> <h2>Recent Posts</h2> <ul> <?php $number_recents_posts = 5;//Enter number of recent of posts you want to display $args=array('numberposts' => $number_recents_posts,'post_status'=>'publish'); $recent_posts = wp_get_recent_posts( $args ); foreach($recent_posts as $post){ echo '<li><a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' . $post["post_title"].'</a> </li> '; } ?> </ul> </li> </ul>
Thanks Neel. Works great. Just what I was looking for.