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 need a way to get just the comments that aren't top level i.e. where parent is not 0.

I've tried:

$args = array(
   'parent' => -0
$comments = get_comments($args);

I know the parent comment id's (44 and 48) of all the comments I require, so I tried:

$args = array(
   'parent' => array(44,48)

$comments = get_comments($args);

But this didn't work. It only returned one row. I need to stick with get_comments() if possible, as I've done a lot of work around it already so want to avoid losing what I've done.

share|improve this question
up vote 3 down vote accepted

You cannot do that with a parameter for get_comments(), but filtering 'comments_clauses' should do it.

Sample code, not tested:

add_filter( 'comments_clauses', 'wpse_78490_child_comments_only' );

function wpse_78490_child_comments_only( $clauses )
    $clauses['where'] .= ' AND comment_parent != 0';
    return $clauses;
share|improve this answer
Fantastic! Thanks Toscho. There is no way I would have worked that one out :) – Chris Jan 6 '13 at 23:14

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.