You’ll need to loop through your posts, use get_comments_number()
to get the number of comments for each post, and then accumulate the total number of comments in a separate variable. e.g.:
<?php
$features_comment_count = 0;
if ( have_posts() ) : while ( have_posts() ) : the_post();
$features_comment_count += get_comments_number();
endwhile; endif;
?>
(I’ll assume that you know how to custom-query your posts, and can adapt the above code as necessary.)
If you want to count the comments before outputting post content, then simply run the above loop, and then rewind posts using rewind_posts()
:
<?php rewind_posts(); ?>
Then, you can output your posts loop as per normal.
Related Posts:
- What is faster: custom taxonomy or serialized post-meta for db retrieval? (over 60,000 posts)
- Query custom taxonomy for category including children
- Trash Bin for Categories?
- Fill New Taxonomies
- Contact Form 7 – Populate Select List With Taxonomy [closed]
- Why is my working Custom Taxonomy not in get_taxonomies array?
- Custom taxonomy on permalink
- How do I filter posts by taxomony using AJAX
- Multiple users – only allow them to manage their own terms for custom taxonomy when logged in
- How to return a list of custom taxonomy terms via the Gutenberg getEntityRecords method
- wp_options table value
- Custom Taxonomy Only Showing Top Level Terms in Admin?
- Get current term’s ID
- Is it possible to get a Previous/Next Taxonomy term archive URL?
- How to modify default taxonomy field to a single text field?
- How to set hierarchical terms to a post using wp_set_object_terms
- How do I display a tag cloud with both post tags AND a custom taxonomy?
- How to link categories to custom taxonomy terms?
- List taxonomy / category count showing list published posts only
- Save Filter for Taxonomies
- Create Child Taxonomies
- Allow only 1 instance of each term in each custom taxonomy
- get_terms: determine if taxonomy term has children
- Set a taxonomy as private
- “show option all” on list categories doesn’t display taxonomy
- Current category link filter
- display taxonomy slug from term ID
- Make a taxonomy column sortable in the admin?
- Redirect all child taxonomy to its parent
- Wrapping result of the_terms in a span with a class of the term name
- How to display custom taxonomy images on index.php?
- How do I taxonomy terms based on terms they are used alongside?
- How can I populate a select element with terms from a custom taxonomy and filter post results?
- How do I list the pages of a custom taxonomy?
- Get number of post who belongs in two taxonomies!
- Get taxonomy based on another taxonomy slug
- Why does a new taxonomy term get created when I assign an existing term to a post?
- Add Image Uploader In Admin Panel
- Tell the difference between a term and page when they have the same ID
- WordPress thinks my custom taxonomy pages are search pages #seo
- Getting associated taxonomies
- How to use multiple archive templates for a taxonomy?
- Custom Taxonomy Query
- WordPress implode & wp_insert_post question
- how can i display taxonomy instead of category on my web page?
- Taxonomy Meta Box in User Profile?
- Proper way to update the slug of a taxonomy using register_taxonomy? [duplicate]
- Displaying Custom Taxonomy without a hyperlink
- Get only immediate children (and not grandchildren) of a hierarchical custom taxonomy term
- How to group all terms children’s in custom taxonomy?
- My custom taxonomy page is leading in 404 page
- Show template part if part of term
- How can I change the output display of my pagination?
- Corrupted nav-menu?
- Remove taxonomy widget from “PAGE” post
- List Top 5 taxonomy terms based on number of post
- How to get product order by two custom taxonomy in wordpress
- Get list of taxonomies associated with users
- Register `product_cat` taxonomy for default post post type
- Custom Taxonomy Not Saving in Front End Post
- Taxonomy.php how to show post only in current taxonomy with wp_query?
- Don’t display taxonomy if empty
- Taxonomize taxonomy terms?
- Use wp_list_categories to list parent categories from actual term
- Include get_term_link inside search
- Set two terms for a post when they differ only by an accent
- Rewrite Search URL Permalink For CPT Custom Taxonomies
- display taxonomy terms with link
- How to add a dynamic dropdown derived from custom taxonomy
- Custom field with terms from another taxonomy programmatically
- Taxonomies and subtaxonomies relations
- Listing Cities A custom taxonmy by selection order
- Template taxonomy-{taxonomy}.php doesn’t show my posts
- Can I get thumbnail of taxonomy?
- Custom Taxonomy Not Being Recognized by is_tax()
- How can I rewrite a custom taxonomy archive slug
- How to truncate the description in the admin panel for a custom taxonomy
- What’s the url queryvar for a taxnomy archive?
- set_object_terms for custom taxonomy in custom post type – not working
- Get all users attached to a taxonomy
- Display taxonomy posts
- Add image to taxonomy and output to homepage
- Extra fields on categories that is available via the WP-API?
- Child Pages and Custom Taxonomies
- Remove taxonomy menu without removing the metabox?
- How to perform a search inside a specific taxonomy category
- Sorting Custom Taxonomy in ASC/DESC order?
- How can i set post_per_page in my taxonamy?
- Exclude 2 in 3 terms of A Taxonomy from all Archives
- Select default taxonomy on dropdown
- WordPress Taxonomy Menu
- Altering term_id and name via $wpdb class
- Loop custom post type by taxonomy (Category)
- get_terms() – unexpected ‘=>’ (T_DOUBLE_ARROW) error
- get_term_children specific no id
- Custom Search only for my Custom Taxonomy Page – data
- Getting taxonomies specific to categories
- Add custom display condition to Elementor Theme Builder for custom taxonomy children, grandchildren, and great-grandchildren
- Add text in custom taxonomy
- How do I check if a post has a term with a particular ancestor/parent?