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

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')));
share|improve this question
up vote 2 down vote accepted

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



share|improve this answer
As I thought. Thanks for the solution! – akashivskyy Dec 27 '12 at 17:33
Make sure both parts are actually arrays. The function can return NULL in some cases, array_merge() will trigger an error then. – toscho Dec 27 '12 at 17:42
Yeah, I know PHP quite well :) – akashivskyy Dec 27 '12 at 17:54
Works nicely for approved and unapproved comments. The merge even supports correct threading for unapproved comments. – Radek Oct 15 '13 at 22:20

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:

share|improve this answer
Seems you know WordPress better than @feeela, but his method is more simple and more convenient. Thanks, for the code, anyway, maybe I will use it in the future. +1 – akashivskyy Dec 27 '12 at 17:33
"Not possible." Well, you provided a solution that made it possible… – feeela Dec 27 '12 at 19:05
It's not possible do do it just like that, you need to filter the sql clause. – akashivskyy Dec 27 '12 at 20:34

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.