Created
September 27, 2012 05:36
-
-
Save palpalani/3792337 to your computer and use it in GitHub Desktop.
WordPres: Latest posts list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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