How get ID all pending comments wp ? I want realizate via loop php, but i do not how get it.

wp_get_comment_status - function is returend only trash', 'approved', 'unapproved', 'spam' status.

  • 1
    I'd guess 'unapproved' are the pending ones. Can you find a comment in pending then check its status in the database?
    – Rup
    Mar 20, 2019 at 14:42

1 Answer 1


get_comments() will get comments for you, either from all across a blog or for a specific post. Its arguments are documented at WP_Comment_Query::__construct().

Unless you've installed a plugin that adds pending as a comment status, you're probably looking for something like this:

$args = array(
     // Limits comments to a specific post.
     // Leave this off if you want all comments, blog-wide.
    'post_id' => $post_id,
    // Get only non-approved (ie, pending) comments.
    'status'  => 'hold',
    // Will only fetch comment IDs.
    // If you want full comment objects, leave this off.
    'fields'  => 'ids',
$comments = get_comments( $args );

If you have installed a plugin that adds pending as a status, you can try using 'status' => 'pending' instead of 'status' => 'hold', since the status argument will allow custom statuses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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