Created
November 29, 2011 14:14
-
-
Save rachelbaker/1404928 to your computer and use it in GitHub Desktop.
Add 5 Most Recent Posts to WordPress Dashboard
This file contains 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
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