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
- 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?
- Skip post in loop and mixin later
- Reverse chronology of post listing
- 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
- Display an author’s posts on his own author page
- A friend wants to make a comment on one of my articles, she has to be logged to wordpress?
- Is it possible to paste a link without tags and make it directly a link in a post?
- Use two different post_per_page limits with infinite scroll
- WordPress Comment posting problem
- How to make the first post in the loop be styled like a “new / featured” post?
- How to setup a query to output posts by groups of five?
- Order posts alphabetically: how to set order=asc in mysql query?
- WordPress website loads more posts than expected
- Howto show comment count by post in post?
- How to add a class to each individual post?
- query post limits
- How can I remove the first two words and shorten get_the_title()
- ACF to select posts not displaying on blog page
- How to check in functions.php if there is data in a WP_Query?
- Querying another post category to match current post and display in loop
- All categories displays the same posts
- how to handle the loop using filling bootstrap grid structure?
- WordPress loop not working on static front page
- Query function not executed between element [closed]
- The loop starting at a certain ID
- Loop not showing first post
- Get posts from current category?
- posts going to 2 pages/categories only show up in 1
- Custom Post Type Single Loop Outputting Wrong Post
- Get current taxonomy and display query accordingly
- Move position in post list for a custom checkbox column
- Multiple post in One Loop in wordpress
- Diffrent layout for posts [duplicate]
- wp_query args with relation
- how to call recent post content in a loop ( only the content before read more tag)
- Show post excerpt
- Show author bio box
- WordPress infinite post cycle problem
- Posting a comment redirects admin/users to blank page
- Show Posts By Custom Field
- List of authors posts minus very latest
- Add something after all sticky posts in The Loop
- How to get only current images of a post
- External link not showing on post but showing on comment
- Is there a way to separate wordpress titles from their posts?
- Redirecting posts in WordPress to a specific page
- Show List of Posts With Comments Open
- When and how will php code in a user made WordPress page be executed?
- Sort Posts Alphabetically Based on Specific Category (Divi)
- Undefined Function Fatal Error with Shortcode [closed]