How to get comments with mixed status using get_comments?

Is there a way to get comments with more than one status using get_comments function?

Let’s say I would like to get both trash and hold comments.

It is possible to do the same with posts:

get_posts(array('post_status' => 'draft,private,trash'));
get_posts(array('post_status' => array('draft', 'private', 'trash')));

What I want to do is:

get_comments(array('status' => 'hold,trash'));
get_comments(array('status' => array('hold', 'trash')));

Solutions Collecting From Web of "How to get comments with mixed status using get_comments?"

As of the WordPress codex there is no such option. But you could just combine two or more comment arrays using plain PHP:

    get_comments( array( 'status' => 'hold' ) ),
    get_comments( array( 'status' => 'trash' ) )

Not possible. You have to filter comments_clauses:

add_filter( 'comments_clauses', 'wpse_77415_comment_clauses_filter' );

function wpse_77415_comment_clauses_filter( $clauses )
    $clauses['where'] .= " ( comment_approved = 'hold' OR comment_approved = 'trash' )";
    // maybe remove the original 'comment_approved' statement …

    return $clauses;

More examples:

  • Get comments for more than one post
  • Get a variable field of all comments of current post
  • How to display only logged in user’s post comments in comments area