WordPress.org

Ready to get started?Download WordPress

Forums

Comment Count (3 posts)

  1. jdcfsu
    Member
    Posted 8 years ago #

    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?

  2. Michael_
    Member
    Posted 8 years ago #

    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...

  3. jdcfsu
    Member
    Posted 8 years ago #

    Thank you for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags