How to Hide Administrator Comments from the WordPress Recent Comments Widget
WordPress's built-in Recent Comments widget displays the latest comments on your blog and allows you to customize the number of comments shown, making it very convenient. However, a drawback is that when an administrator replies to a blog commenter, their reply is also displayed. This can cause the Recent Comments widget to be filled with the administrator's own comments, resulting in a poor user experience.

Recent Comments
Solving this problem is very simple. You just need to add the following code to the functions.php file in your theme directory:
// Hide administrator comments from the homepage
// Check the WP_Comment_Query::query section in wp-includes/comment.php
// Refine the query conditions based on passed parameters
add_filter( 'comments_clauses', 'wpdit_comments_clauses', 2, 10);
function wpdit_comments_clauses( $clauses, $comments ) {
global $wpdb;
if ( isset( $comments->query_vars['not_in__user'] ) && ( $user_id = $comments->query_vars['not_in__user'] ) ) {
if ( is_array( $user_id ) ) {
$clauses['where'] .= ' AND user_id NOT IN (' . implode( ',', array_map( 'absint', $user_id ) ) . ')';
} elseif ( '' !== $user_id ) {
$clauses['where'] .= $wpdb->prepare( ' AND user_id <> %d', $user_id );
}
}
//var_dump($clauses);
return $clauses;
}
// Check the WP_Widget_Recent_Comments section in wp-includes/default-widgets.php for details
// Add the not_in__user parameter
add_filter( 'widget_comments_args', 'wpdit_widget_comments_args' );
function wpdit_widget_comments_args( $args ){
$args['not_in__user'] = array(1); // Enter your user ID here;
return $args;
}
//END
After applying the code, you will see that the Recent Comments widget on the right side of your website will no longer display comments from the administrator (e.g., Xiao Z), showing only recent comments from users.