Exclude child comments in get_comments() or WP_Comment_Query?

How do I only get the first level of comments in get_comments() or WP_Comment_Query? I want to query the comments which have 'comment_parent' => 0, and exclude all the child comments.

    $args = array(
        'number'      = 10,
        'order'       = 'DESC',
        'status'      = 'approve',
        'meta_key'    = 'comment_parent',
        'meta_value'  = 0
    );

    $comments = get_comments( $args );

Topic wp-comment-query comments query Wordpress

Category Web


This should do the trick, I guess:

$args = array(
    'number'      => 10,
    'order'       => 'DESC',
    'status'      => 'approve',
    'parent'      => 0
);

$comments = get_comments( $args );

You can find full list of arguments in Codex.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.