I wonder if you’re looking for the wp_count_comments()
function.
To retreive comment count statistics for the whole site, you can use:
$comments_count = wp_count_comments();
or for a given post ID:
$comments_count = wp_count_comments( 123 );
It will return an object with the following attributes:
$comments_count->moderated
$comments_count->approved
$comments_count->spam
$comments_count->trash
$comments_count->total_comments
Check the Codex for more information and examples.
Related Posts:
- Disable comments on all posts/pages
- Stop WordPress redirecting comment-page-1 to the post page?
- Importing old Disqus comments into WordPress
- How to add a class to the comment submit button?
- Would switching to InnoDB from MyISAM improve performance of comments table?
- Linking to Page Showing Only Comments Without Parent Post
- Post Comments using WP REST API v2 in WordPress
- Show content only if member left a comment
- How to auto-approve internal pingbacks?
- Using filter to add additional fields to comment_form()
- Disable wordpress comments API
- List Recent Comments from Across a Multi-site Network
- Comments waiting but no comments found
- Programmatically block commenting by restricting view of comment form
- How to override function twentyten_comment
- Disqus over the default commenting engine, what are some pros and cons?
- Comments screen in backend, how to disable Quick Edit | Edit | History | Spam | for non admins
- How To Remove The “Click here to cancel reply” Link From The WordPress Comment Form
- Plugin from WordPress.com for comment notification…available? [closed]
- How to add text to comment form #content textarea?
- Get most active users sort by comment count
- Passing arguments to wp_list_comments callback function
- What are the additional fields in wp_comments used for?
- comments_template not working correcly in custom template files
- How can I highlight admin comments?
- Why are my comments closed?
- Block comments from search engine indexing
- Create a “Reject” action for comments?
- How to change style of Disqus comment count on main page
- Adding another arg to comments_popup_link
- List User Comments on User Profile BuddyPress [closed]
- Changing “submitted on date” of comments
- Filter custom comment type from Manage Comments & Dash Widgets
- How to allow more HTML tags in comment for a certain comment_type
- How to deal with spam comments and distinguish them from non-spam comments?
- WordPress custom form action url
- How to add a strip of visual editor on top of comments textarea
- Threaded comments not working
- Customizing comments pagination for bootstrap
- woocommerce allow users to select or use avatar
- Error While Sending Comment
- How to get all comment authors of a single post?
- Get return value of wp_insert_comment (comment ID)
- comment_reply_link not work with me
- have_comments() does not work
- How to use the ‘comments_number’ filter?
- How to allow duplicate comments AND without comment text
- Remove the deleted user comment
- Only allow the post author and admin to comment on a post
- Repositioning ‘Reply’ Link in Comments
- Add an attachment feature to comments
- Cannot post comments if I don’t post a website?
- How Do I Allow Comment Moderation for Other User’s Posts?
- Counting Comments as Singular and Plural in comments.php Template
- How to display custom comment fields onto any page
- Make every comment go to the spam folder
- Limit number of comments from get_comments()
- Correct way to retrieve comment attributes for desired results
- The comment could not be saved. No comment_ID on comments
- How to get Post title by locale with Qtranslate-X
- ‘comment_post’ hook doesn’t seem to work? [closed]
- Admin Dashboard – Recent Comments source
- After submit comments select the current tab
- count number of all comments by a user on different (non-repeated) posts
- Facebook comments widget – App ID
- Comments screen in backend, how to disable visual editor when replying to a comment
- Adding a comment link to the top of every post
- WordPress comment reply link image
- Custom comment types. Are they a possibility?
- Comment form in wordpress theme returns a javascript alert
- Embedding local video in WordPress comments
- How to add inside WordPress comments loop?
- Difference between date and date_gmt
- How do I edit Comments.php so I can add Schema markup to comment output?
- Author name length character limit?
- Check if comment author has url
- Migrate comments and likes wordpress.com to selfhosted site
- How to enable truly anonymous posting in bbPress forums? [closed]
- Admin – Dashboard – Unset recent comments
- Prevent author from editing comments from others in their post
- Display Most Recent Three Comments Per Post
- How does WordPress generate a comment website preview?
- Front End User(bloger) turn on and off his comments
- Does not show comment list
- Can’t post comment to blog in wp-multisite
- Display Comment Form on dedicated Page for each post
- Change comment author after new comment posted
- Show ‘add comment’ link for status updates in Twenty Thirteen
- Pull & display new comments without refreshing the page
- How to display comments by logged in user and responses?
- Identify and display the fact that user is admin next to username in comment section
- Display facebook comments made on site
- Disable Link to Post from Showing Up in Post’s Comments?
- Email from new comments
- Image Upload Form is Disabling Comment Addition
- db query for retrieving comments without any reply
- Embed a page within WordPress dashboard?
- Clicking Comment “Reply” Button only replies to first comment
- How to add a comment box on wordpress page? in the discussion section of page, allow comments is checked
- Auto delete WordPress comments