To print just the total number of comments for a given post ID, use the count argument:
echo get_comments(
array (
// post ID
'post_id' => 149,
// return just the total number
'count' => TRUE
)
);
or just use
// Argument: Post ID
echo get_comment_count( 149 );
To get the total number of all comments of all posts on the current page, you can use the comment_count property of the post objects and sum them up:
echo array_sum(
wp_list_pluck( $GLOBALS['wp_query']->posts, 'comment_count' )
);
Related Posts:
- How to get posts published between a date and today?
- Display all posts from specific categories on a page
- get comments and get posts in loop
- How to exclude latest x posts from a paginated query?
- Display content from a specific category
- Only display posts with comments
- How to Display Post View Count
- Display posts with comments closed, with pagination?
- How would I get 1 latest post from a query for 5 posts?
- Inserting custom data to the_post() during loop
- How To Get Posts With A Specific Word
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Display all posts that were published before full post on single.php
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- How to order posts in an arbitrary order?
- Display Posts on Custom Page
- Wrong post title displayed from loop
- Get the amount of posts on a current page
- How to get posts published on the latest date?
- How to only publish posts with image in it
- WP_Query: Show 10 posts in date order, first three random
- Display specific posts on home page
- Display 3 posts with different HTML markup using a loop
- Shortcode for Comments and Comment Boxes in Post Loop
- How to show post views shortcode data for each post on Posts List Page?
- Use special template for the first post in the loop
- Modify WordPress loop after it has been run
- show latest authors blog post
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Adding a category at even positions on main loop with modified pagination
- How to inject a post within a loop
- wp_query select if have comments
- Why does ‘get_the_ID’ work outside of the loop?
- Keep featured content post in homepage with original order
- How set featured posts using checkbox in post edit screen?
- WP_Query: Why is sticky post not first item in loop?
- how to display full post with pagination on home page
- This AJAX Code Doesn’t Work – Looking for elegant solution
- WordPress get posts by date without query_posts
- Featured Posts for Category Pages
- Cannot Update A Post, 404 Error
- Hiding posts in a list from specified categories
- Disable Post/Page comment emails for creators
- Group posts by year in loop
- Create dropdown list post
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- get_next_post() and get_previous_post() return wrong posts
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Display post from current category and same tag?
- Random ajax load only works with posts_per_page set to -1
- Get Image tag from content of post
- A friend wants to make a comment on one of my articles, she has to be logged to wordpress?
- How to add tags (custom taxonomy) to post class css?
- Listing Specific Categories from Current Post with Depth
- get_the_category listing in hierarchial order
- Internal post link creates comments on its own
- Nested WP_Query breaking loop
- SQL Command for restoring trashed comments
- Custom taxonomy archive page problem
- Loop don’t work within single.php page
- Query for first 3 posts to change the look and feel
- Getting blog pagination to work on page set as front page
- Make loop inside slider divisible [closed]
- How to display post list in a table layout (multiple queries in single loop)
- Not all posts showing in query
- WordPress query portfolio posts
- How to get posts ordered by using their categories?
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- How to repeat a loop after 4 posts [duplicate]
- How to assign a post to a post parrent?
- get parent fields title, content excerpt etc
- Is there a way to define the $post var outside the loop?
- AWS usage queries
- Only the most recent post is showing on my category page (working on localhost, not live site)
- How to fetch courses in all languages in WordPress?
- Assign a day of the week to post, e.g: Assign Monday to post and have it only appear when the day is Monday
- Show 5 posts and than 3 posts offset with pagination
- Alternative content between posts no repetition
- Start loop from specific post ID
- Display new posts categories in separated divs
- Add row after three columns
- index.php is only displaying current month’s posts?
- Ordering posts alphabetically by meta keys and title
- Loop doesn’t display posts. It displays a link to the home page instead
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- Grab next post title in archive page
- Remove duplicated posts in the loop if post has more than one category
- Getting posts from multiple users?
- single.php fires more than once after clicking on any post to view with different post id each time
- 2 tick boxes appearing below comments
- Show all posts in category
- First post in loop displays twice
- How can I show the positive and negative comments for a same post separately?
- What function does the loop of displaying posts?
- Global $post value outside the loop
- List of published post dates only outputting one date
- How to show related posts by detecting the current category?
- Display posts on a custom page from only a specific category?