Hide Number of Comments if None in WordPress

Just a quick one to tidy up your blog a little and make it a little less negative! It’s quite common to see a list of posts on a WordPress blog with meta info underneath each one displaying things like Post Time, Post Category, Author and the number of Comments the article has. For smaller blogs, there probably wont be too many comments left so you’ll see “No Comments” or “0 Comments” under a lot of the posts. I’ve always thought this looked a little sad on my own blog. Like, here I am slaving away on these excellent and informative articles and no one is reading or commenting on them!? Here’s a quick code edit to hide the “No Comments” text if there are none but show the number of comments and link to them if there are any.

Open the index.php file for your theme in a HTML editor and look for a line similar to this:

<?php comments_popup_link(‘0 Comments’, ‘1 Comment’, ‘% Comments ‘); ?>

Change this to:

<?php comments_popup_link(”, ‘1 Comment’, ‘% Comments ‘); ?>

You’re just deleting any text that should be displayed when there are no comments so if there are none, then nothing will be shown. Geddit!?

You might need to edit this line in several other template files also such as Archive.php, Category.php, Search.php, Tag.php and anywhere else comment numbers are displayed.


Published by

Leon Quinn

Multimedia Design company in Leitrim, Ireland specializing in WordPress Website Design, Photoshop and Graphics.

4 thoughts on “Hide Number of Comments if None in WordPress”

  1. Hi Leon,

    Tried this on my site above and no joy. It there any where else I need to change this line. Only found the exact line in the index.php and not in the others eg comments.php?

    Any thought, pls!



    1. It should really have worked if you done it properly and are displaying all your posts on the home page, however, I don’t see any reference to comments at all in your home page articles? I only see a comment number reference on the actual article page itself so you should probably look at your “single.php” template file instead. All templates are wildly different so bare that in mind.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.