Skip to content

Instantly share code, notes, and snippets.

@brandonhimpfen
Created February 1, 2014 19:42
Show Gist options
  • Save brandonhimpfen/8757590 to your computer and use it in GitHub Desktop.
Save brandonhimpfen/8757590 to your computer and use it in GitHub Desktop.
Creates a list group of the last 5 posts in WordPress, using Twitter's Bootstrap panel. More or less of 5 posts? Change line 2.
echo '<div class="panel panel-default"><div class="panel-heading">Last Five Posts</div><div class="panel-body"><p>Here are the latest posts:</p></div><ul class="list-group nav">';
$args = array( 'numberposts' => '5' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="'.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a> </li> ';
}
echo '</ul></div>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment