diff --git a/inc/fun/widget.php b/inc/fun/widget.php index 822162cc..0b8cda2f 100755 --- a/inc/fun/widget.php +++ b/inc/fun/widget.php @@ -490,20 +490,27 @@ function widget( $args, $instance ){ global $wpdb; $comments = pk_cache_get(PKC_WIDGET_NEW_COMMENTS); if(!$comments){ + // $sql = "SELECT comment_ID as id,comment_post_ID as pid,comment_author_email as mail,comment_author as `name`,comment_author_url as url,comment_content as text + // FROM $wpdb->comments WHERE user_id !=1 and comment_approved=1 order by comment_date desc limit 0,{$nums}"; $nums = $this->get_num_val($instance, 'nums'); - $sql = "SELECT comment_ID as id,comment_post_ID as pid,comment_author_email as mail,comment_author as `name`,comment_author_url as url,comment_content as text - FROM $wpdb->comments WHERE user_id !=1 and comment_approved=1 order by comment_date desc limit 0,{$nums}"; - $comments = $wpdb->get_results($sql); + $args = array( + 'number' => $nums, + 'date_query' => array( + 'before' => 'tomorrow', + 'inclusive' => true, + ), + ); + $comments = get_comments($args); pk_cache_set(PKC_WIDGET_NEW_COMMENTS, $comments); } $this->get_common_widget_header($instance); ?>