Latest Tech and Tips

Display the Most Accurate Comment Count in WordPress


When you are presenting comment count it is constantly great to display the accurate comment count. WordPress by default includes your trackbacks and also pings right into the overall count which in fact blows up the count. Specially some blog sites that does disappoint trackbacks, or has them divided from the remarks, you require to make certain that you are presenting the appropriate count. In this write-up we will certainly reveal you exactly how you can display the right comment count via a tiny fragment which will certainly remove trackbacks and also pings and also just display the real comment count to your individuals.

Open your functions.php which lies in your theme folder. And Paste the adhering to code in there:

add_filter(' get_comments_number', 'comment_count', 0);.
feature comment_count( $count) {
if (! is_admin()) {
international $id;.
$ comments_by_type = && separate_comments( get_comments(' condition= authorize&& post_id='. $id));.
return count($ comments_by_type['comment']);.
} else {
return $count;.

With this fragment, you can currently reveal the most accurate comment count to your blog site individuals.