Hide Number of Comments if None in WordPress
>> Only show Comment Numbers if there are any....
This post was published 1 year 8 months 15 days ago which may make it a bit inaccurate or irrelevant today. Things change and I cant keep checking old posts for validity. I wont be held responsible for any misunderstanding. Leon - Reverb StudiosJust 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.
Leon.
This Article has had 980 views so far.
Posted in How to Guides, Wordpress Tips on September 2nd, 2010
Follow responses to this article through the RSS 2.0 feed.
leave a Comment, or Trackback from your own site.
-
http://www.ivanwalsh.com Ivan
-
http://www.patiowindowtreatments.net patio window treatments
-
http://www.mapsofireland.ie Maps of Ireland
Thanks for checking out my Site! I'm a Multimedia/Web Designer based in Leitrim, Ireland. Leon.
-
Login/Register:
REGISTER to Automatically receive New Posts via Email as they are published. LOGIN below if you're already registered.













