Use get_comments_number()
to determine the number of comments, and prepare the CSS class with that information:
$css_class="zero-comments";
$number = (int) get_comments_number( get_the_ID() );
if ( 1 === $number )
$css_class="one-comment";
elseif ( 1 < $number )
$css_class="multiple-comments";
comments_popup_link(
__( 'Post a Comment', 'your-theme' ),
__( '1 Comment', 'your-theme' ),
__( '% Comments', 'your-theme' ),
$css_class
);
Related Posts:
- How to show Disqus comment count number only without text?
- Can’t seem to get this CSS to work…any ideas why? [closed]
- css hide all the comment reply links except the lowest nested comments
- Which filter/hook to use for styling comments?
- Applying same style to all the comments on the page
- Highlight comments made by registered users of the site
- JetPack comment threads are displaying above comment box? [closed]
- Styling Admin comments in WP 3.1.3
- Add option to disable comments on a per posts basis?
- comments reply script not working
- What should I do to make generated avatars different for anonymous comments?
- Check If comment author is registered
- How do I set up real anonymous posting in bbpress forums? [closed]
- How do I turn off wordpress comments ability to capture a users ip address?
- Success message in comment form
- How to allow the reply link to remain on the comment form after I have reached my 10 nested comment limit?
- Is there a hook for comment author link?
- How can I edit the email sent when a new comment is received?
- Exclude internal links from comment moderation?
- Change the HTML output of comments
- How to Block Access to Standard Login Flow and Comment Flow
- Upload images with comment
- Prevent Contributor to show comment list
- where to modify get_comment_author_link()?
- Change language of comments template
- Why Allow Script Commands in Comments?
- How to enable comments options?
- WordPress comment count to include attachment comments
- How to no follow the paginated comments
- Remove “Comments are closed” Notice from Custom Post Type template
- Displaying comments with a walker: how to distinguish between parent and child comments
- Count parent comments & replies separately?
- Comment form problem with comment_author_url and HTML5 input placeholders
- How would I count the number of times a comment meta field’s value is in a post’s entire comments?
- Pings and replies
- stackexchange-like submit comment window
- Comment_Reply_Link Not Showing?
- Cannot get local avatars to show [closed]
- Limit user to one comment
- Display the number of unseen comments on a page since the user last visit
- Log in link not showing, Comment Issue
- WordPress comments on users profile
- wordpress threaded comments – customize nested ul / how child ul is displayd
- How to make a secure blog that is completely private?
- identify and delete spam comments from 3000 pending comments
- Hide comments column in WordPress backend
- How unrequire comment text in wordpress post
- Auto delete comment if Contains
- How to limit comment author to one comment per post
- API Hook for After Commenting (for sharing on Facebook)
- Make WordPress process admin group comments using $allowedtags
- Can comments by a logged-in user be displayed at the top?
- Placed on + only date (not time)
- Loading Comments From a Class?
- Incorrect redirection after commenting on custom type
- have_comments not true for logged out visitors?
- WordPress for questions and responses website
- Anonymize comments after one year
- How to Add text to the start of all comment?
- How to get comments other than using wp_list_comments?
- How many members have made comments approved for an article?
- How to get a value from comment meta
- reCaptcha doesnt appear in comment (manual or plugin)
- Add a Comment on/off option in Screen Options for Comments?
- Comment System showing different type of IP
- Only Allow post author and “Premium” Role user to comment
- Exclude the word comment from being referenced
- How to open up comments to all visitors
- What is the earliest hook comment meta can be saved?
- assumed as comment line
- stumped on add_action hook to delete_comment – any ideas?
- Avoiding calls to theme-compat
- Allow tags between shortcode in comments
- How to load new posts from wordpress db into wordpress homepage without refreshing the site?
- Delete/Spam Comment Button
- Who approved a comment, to show up in dashboard
- comments.php remove date/time’s #hyperlink
- comment just attachment .. reply just text … can I do that?
- I have an odd field with a purple background, mentioning HTML-codes to use while leaving comments
- No comment Section but still got a Comment
- How to prevent users/authors from seing IP/email of new commentators?
- Why are my threaded comments not quite working? [closed]
- $post->comment_status always returns ‘closed’
- Order comments in admin by custom date
- edit comments in front end
- How to replace anonymous comment form with a registration form on wordpress?
- I have tried using Plugins to remove 72K comments with no success
- How to get the 5 most recent comments and each comment 5 most recent replies (children)
- Redirect first time comments
- Posting XML in comment section
- comment files and s
- Comments – Ensure the correct field is highlighted for nested replies
- Disqus moderation page not working in WordPress admin section
- How to hold all comments for moderation, including author’s comments on own post
- Comment forum to display under the comment you’re replying too
- Recent comments per tagged post?
- Subscribe to a post’s comments without posting a comment yourself
- WordPress error when sending comment
- How to hide the login / profile urls on top of comment box for a post
- Why default comment fields don’t show up?