WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use comments with a custom comment type in my plugin to notify users of various events created by the plugin.

The problem is I don't want these cluttering up the standard comments so I need to filter out those custom comments from the manage comments screen as well as the recent comments dashboard widget.

Does anyone have any ideas on how to do this?

share|improve this question
How is your plugin making these 'custom comment type'. I do not know of any native WordPress way for custom comments. – imHavoc Jan 22 '12 at 21:50
By using wp_inset_comment($args). One of the fields in wp_comments is comment_type which can be either '' for normal comments, or ping/track, or whatever you like codex.wordpress.org/Function_Reference/wp_insert_comment – studioromeo Jan 22 '12 at 21:53

Doh, looks like the answer was staring me in the face.

add_filter( 'comments_clauses', 'myPlugin_exclude_custom_comments', 10, 1);
function myPlugin_exclude_custom_comments( $clauses ) {

    // Hide all those comments which aren't of type system_message
    $clauses['where'] .= ' AND comment_type != "system_message"';   

    return $clauses;

What this does is edit all comment queries to find comments that don't have a type of system_message

Hope this helps someone :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.