• Resolved themooknet

    (@themooknet)


    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)
  • 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

    (@themooknet)

    Thanks, Andy! Looking forward to it.

    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.

    Sorry, could you help me please?

    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.