WordPress ships with a nifty widget to show your most recent comments. There are a number of ways to modify it
- Use a plugin and change everything
- Copy the widget code from wp-includes/default-widgets.php into your theme’s functions.php and tinker away
- Use the widget_comments_args filter
I’m not big on plugins. Option 3 is pretty clean and light and it’s what I’ll explain here.
In your theme, open functions.php and paste this:
function mythemename_alter_comments( $args ) { $args = array( 'number' => 5, 'status' => 'approve', 'post_status' => 'publish' ); return $args; } add_filter( 'widget_comments_args', 'mythemename_alter_comments', 10, 1 );
Replace ‘mythemename’ with your theme name. Change the values in
array( ‘number’ => 5, ‘status’ => ‘approve’, ‘post_status’ => ‘publish’ )
to suit your needs
For the full list of parameters you can use (and their default values), read this http://codex.wordpress.org/Function_Reference/get_comments
Use this method if you want to get your recent comments but don’t want to go through the hustle of styling them. Naturally, another option is to use the get_comments function and style everything