Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rachelbaker/1404928 to your computer and use it in GitHub Desktop.
Save rachelbaker/1404928 to your computer and use it in GitHub Desktop.
Add 5 Most Recent Posts to WordPress Dashboard
function rb_recent_posts_dashboard() {
?>
<ol>
<?php
global $post;
$args = array( 'numberposts' => 5 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li> (<? the_date('Y / n / d'); ?>) <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ol>
<?php
}
function rb_add_recent_posts_dashboard_widget() {
wp_add_dashboard_widget( 'rb_recent_posts_dashboard', __( 'Recent Posts' ), 'rb_recent_posts_dashboard' );
}
add_action('wp_dashboard_setup', 'rb_add_recent_posts_dashboard_widget' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment