Wordpress Comment count


/ Published in: PHP
Save to your folder(s)

Count commetns and return value into the post


Copy this code and paste it in your HTML
  1. <h1><?php
  2. $commentscount = get_comments_number();
  3. if($commentscount == 1): $commenttext = 'comment'; endif;
  4. if($commentscount > 1 || $commentscount == 0): $commenttext = 'comments'; endif;
  5. echo get_the_title().' ('.$commentscount.' '.$commenttext.')';
  6. ?></h1>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.