Skip to content

Instantly share code, notes, and snippets.

@palpalani
Created September 27, 2012 05:36
Show Gist options
  • Save palpalani/3792337 to your computer and use it in GitHub Desktop.
Save palpalani/3792337 to your computer and use it in GitHub Desktop.
WordPres: Latest posts list
/*
* List of recent posts
*/
function m3_last_posts(){
$args = array(
'no_found_rows' => 1,
'post_status' => 'publish',
'posts_per_page' => 5
);
$latest_posts = new WP_Query( $args );
/*
echo "Last wp_last_posts-Query: {$latest_posts->request}";
*/
while ( $latest_posts->have_posts() ) : $latest_posts->the_post();
echo '<div class="post m3-posts">';
if ( has_post_thumbnail() ){
printf('<a href="%s" title="%s" rel="bookmark" class="post-thumbnail alignleft">%s</a>', get_permalink(), the_title_attribute( 'echo=0' ), get_the_title() );
}
printf('<h2><a href="%s">%s</a></h2><p class="byline post-info"><span class="date published time">%s</span></p>', get_permalink(), get_the_title(), get_the_time(get_option('date_format')));
echo '</div><!--end m3-posts -->';
endwhile;
wp_reset_query();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment