Title: Code to Exclude Admin Comments
Last modified: June 11, 2017

---

# Code to Exclude Admin Comments

 *  Resolved [themooknet](https://wordpress.org/support/users/themooknet/)
 * (@themooknet)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/code-to-exclude-admin-comments/)
 * Hello!
 * I recently found and added the below snippet to my theme’s functions.php to exclude
   my comments (the admin’s) from the default WP Recent Comments. However, I much
   prefer the look of this plugin’s Better Recent Comments widget.
 * I feel like if I were smart enough to figure out what to change “widget_comments_args”
   to, this snippet would work with Better Recent Comments as well. Is that not 
   the case? If it is the case, what would I change it to?
 * Thanks!
 * function ra_recent_comments_less_author( $array ) {
    global $post; $array[‘user_id’]
   = !$post->post_author; return $array; } add_action( ‘widget_comments_args’, ‘
   ra_recent_comments_less_author’ );

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Andy Keith](https://wordpress.org/support/users/andykeith/)
 * (@andykeith)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/code-to-exclude-admin-comments/#post-9226689)
 * Hi,
 * Sorry for the slow reply. For some reason we haven’t added a filter for the comment
   args, as the default widget does. However we will definitely add that in the 
   next version. Once this is done, you can add this code to exclude posts by author:
 *     ```
       function brc_comments_less_author( $args ) {
          global $post;
          $args['post_author__not_in'] = $post->post_author;
          return $args;
       }
       add_filter( 'better_recent_comments_comment_args', 'brc_comments_less_author' );
       ```
   
 * I’ll update this thread when this filter becomes available.
 *  Thread Starter [themooknet](https://wordpress.org/support/users/themooknet/)
 * (@themooknet)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/code-to-exclude-admin-comments/#post-9229712)
 * Thanks, Andy! Looking forward to it.
 *  [Pablejacio](https://wordpress.org/support/users/pablejacio/)
 * (@pablejacio)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/code-to-exclude-admin-comments/#post-9299090)
 * Hello Andy!
    I have tried adding the code you wrote in my functions.php to exclude
   the administrator comments in my widget. But it didn’t work… Do you know what
   else could I do? Thank you very much.
 *  [Pablejacio](https://wordpress.org/support/users/pablejacio/)
 * (@pablejacio)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/code-to-exclude-admin-comments/#post-9357560)
 * Sorry, could you help me please?
 *  [Andy Keith](https://wordpress.org/support/users/andykeith/)
 * (@andykeith)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/code-to-exclude-admin-comments/#post-9357624)
 * Hi,
 * Sorry for the slow reply. The plugin doesn’t currently support that feature I’m
   afraid, but you could get a developer involved to customise it to meet your requirements.
 * Many thanks,
 * Andy

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Code to Exclude Admin Comments’ is closed to new replies.

 * ![](https://ps.w.org/better-recent-comments/assets/icon.svg?rev=3100094)
 * [Better Recent Comments](https://wordpress.org/plugins/better-recent-comments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/better-recent-comments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/better-recent-comments/)
 * [Active Topics](https://wordpress.org/support/plugin/better-recent-comments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/better-recent-comments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/better-recent-comments/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [Andy Keith](https://wordpress.org/support/users/andykeith/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/code-to-exclude-admin-comments/#post-9357624)
 * Status: resolved