free tuts

There are few ways to show number of comments on your post. Here are two methods to display comments’ number. One is to show comment number only. Second one is to show not only number of comments but corresponding text as well. In this method if there are no comments, website visitor will see “No comments yet” annotation. If a post is password protected, a website visitor will see “Enter your password to view comments”. So, here we go.

Method 1 code:

We add this piece of code inside single.php or index.php or any other related template file. It should be inside the loop. And visual result is:

comment-closeup

Method 2 code:

Visual result is:

comment-closeup2

Method 2 is actually mentioned in WordPress Codex along with other fuctions related to comments. Annotations like “Enter your password to view comments” can be found inside core file comment-template.php in “wp-includes” folder. If you want to remove a dot after this annotation (line #1239) you have to open this file in editor, remove dot and reupload comment-template.php onto your server. In general, it is not recommended to touch WordPress core files, but there is nothing frightening in this case, indeed. Of course if you develop a theme, free or paid which will be downloaded by other users it will not help, but for your own website it can be done and done easily. Naturally, with every new update of WordPress this change won’t save, mind it.

Limpopo

©2014-2018