On most cases you should be able to use the_title filter to modify the title string. Use get_comments_number() to get the comments count for the post – of given ID or the current one.
For example,
add_filter( 'the_title', 'wpse_427277_the_title', 10, 2 );
function wpse_427277_the_title( string $title, $post_id = null ): string {
$comment_count = (int) get_comments_number( $post_id );
if ( $comment_count ) {
$title .= sprintf( ' (%d)', $comment_count );
}
return $title;
}
Modify as needed.
Related Posts:
- Count singular post views automatically
- How to Orderby Comments by post title?
- Howto show comment count by post in post?
- How to style archive post titles… but only those posts who have comments?
- If post exists, make it a comment in existing post with same name?
- Count the total views of all user posts published
- Count singular post views automatically
- How to mark every 3rd post
- How to change the case of all post titles to “Title Case”
- Apply the_title() filter in post & page title, but not in menu title
- How to make comments work for a post loaded per Ajax?
- Count posts within a custom post type and specific taxonomy and terms?
- How to Display a List of Users Who Have Made at Least 1 Post?
- Hook that get’s triggered when the author of a post is changed
- How to Display Network Post Count?
- Remove post title input from edit page
- The hook for the AJAX Add to Cart button?
- Get old values for post before saving new ones
- Allow variable amount of comments before pagination
- Execute function when post is published
- how to limit edit_form_after_title hook to page and post edit only?
- Set Post Title to Read-only and Disable Permalink Slug Editor in Gutenberg
- get comments and get posts in loop
- How to cache a shortcode functions output?
- Disallow Same Post Title
- Get title of post without using the_title();
- Verify if tag is used on posts
- Action hook ‘wp’ firing twice… why?
- Count posts in category including child categories
- Dynamically update post title in admin page
- How to display comments and comment form on custom post type?
- In what sequence are the hooks fired when a post is “published”?
- Comments are assigned to wrong or related post
- How can I allow editors to leave comments on posts that have not yet been published?
- Update post date on every new comment?
- Better post meta efficiency?
- How to show posts rank based on custom field value
- Set font size automatically according to number of words in post
- One comment per user email per post
- Can’t show comments count per post outside loop
- How to change post status from publish to draft using hook in wordpress?
- Only display posts with comments
- Network wide post count (WP Multisite)
- Comments enabled, but disabled at the same time
- Filter post before *editing*
- Comments not showing in custom post type – WordPress
- Redirect based on user post count
- WordPress Delete hook with wp_delete_post function?
- How to output comments number of a post per day?
- Alternate custom content in the loop
- Enable commenting on front-end preview page for pending posts
- Hide comments awaiting moderation from user who submitted the comments
- Displaying Page Title on index.php
- Custom function for “Submit for Review” hook
- First hook to use current page post id
- Show that current post is number X out of X
- How to place HTML below the title of the (custom) post overview
- How can I hook into creating a new post and execute wp_die(), before the post is inserted into the database?
- How to intercept Post Title on Post-Save
- Testing for post title in ‘if/else’ statement returns no content
- get_post_field – Title without paragraph
- Hide Post comments when displayed via WP_Query
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- Including new Javascript only after a comment is made
- Add Category name to Post Title (h1)
- How to add a custom field after wp post
- Does an action fire when adding a tag via the “Tags” meta box?
- Disable Post/Page comment emails for creators
- Double count view in archive.php
- Sorting posts alphabetical that have single digits
- Display posts with comments closed, with pagination?
- How Can i Get 5 Recent Post Title With Corresponding Link?
- Why is WordPress redirecting users to random posts after commenting?
- How to get most recent commented post above new submitted post in WordPress?
- Are posts updated or built from revisions + autosaves?
- How can i do something after head like adding a hook for after head but before post
- Count to how many categories a post belongs to
- When trashing a post, also trash related comments
- how to find user ids of all commenters in a post
- I want to show category in the post title , how can I do
- Diplay comment date on WP_Post_Comments_List_Table
- Count total number across post types
- How to prevent WordPress from updating the modified time?
- Count search results in heading
- How to hide first gallery for every post?
- How to display following posts titles in separate div’s on a separate webpage
- Posts vs. Pages
- Action hook for new pending posts?
- Blog Posts not showing title
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Lose “Blog Archive” from page title
- count the total number of comments the user has received for his published posts
- Register post status, exclude from searches
- Counter of posts ever posted – even deleted ones
- Display Published Posts Count for Certain Time Period
- If modified on same day, show only time
- WordPress not opening posts with only numbers if permalink is post_name
- How to allow logged in users to post anonymously
- How to modify post content?
- Email entire post contents