WordPress.org

Support

Support » Themes and Templates » Comment Count

Comment Count

  • I am using the code <?php echo $commentcount++;?> to supply the comment number behind the comment text, though it skips the first comment when numbering and puts a “1” behind comment number “2”. How do I fix this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Just add
    $commentcount = 1;
    above the loop.
    The reason is that the “++” is called AFTER the echo.
    So in the first comment the $commentcount is not yet defined, therefore nothing is being displayed.
    I suggest to use “error_reporting = E_ALL” in your php.ini of your development environment so that you get error notices, which are quite helpful when developing…

    Thank you for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Comment Count’ is closed to new replies.