'Recent Comments', 'comments_number' => '5', 'display_author' => 'true', 'display_comment' => 'true', 'display_avatar' => 'true', 'read_more_text' => '»', 'comment_length' => '50', 'avatar_size' => '32', 'avatar_align' => 'alignleft' ); class Comments extends WP_Widget { function __construct() { $widget_options = array('description' => 'Advanced widget for displaying the recent posts with avatars' ); $control_options = array( 'width' => 400); $this->WP_Widget('comments', '» Comments with Avatars', $widget_options, $control_options); } function widget($args, $instance){ global $wpdb; $title = apply_filters('widget_title', $instance['title']); $comments_number = $instance['comments_number']; $query = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,50) AS com_excerpt FROM ".$wpdb->comments ." LEFT OUTER JOIN ".$wpdb->posts." ON (".$wpdb->comments.".comment_post_ID = ".$wpdb->posts.".ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT ".$comments_number; $comments = $wpdb->get_results($query); ?>