• Hi,
    currently, the only way to get a number associated with a comment is to use the

      tag. That is the default of WP layout. So for each comment, you get a number associated with it. If you want to post a comment, you’ll clearly see you’re the (let’s say…) seventeenth (17).
      That is ok.
      But what if we wanted to put this number elsewhere, thus NOT being able to use the

        tags. For example, how could we get this number to appear inside the comment itself after it’s been posted ?
        Using comment_ID() isn’t a solution since the outputed number is incremental but relative to the whole database. I’m looking for a solution to create and output a incremental number per post.
        I hope I make sense and that someone could contribute with his genious idea. ??

      Viewing 6 replies - 16 through 21 (of 21 total)
      • Thread Starter chiensavant

        (@chiensavant)

        That is certainly something that I would love to see working. But so far it is not supported by any browser.
        So I’m still looking for a better solution. I’m looking into a SQL oriented solution at this time…

        Why not try this… Enter /wp-comments.php and change this section:
        foreach ($comments as $comment)
        To this:
        foreach ($comments as $comment_id => $comment)
        Then anywhere in that loop you just have to call something like:
        <?php echo $comment_id++; ?>. I’m sure if you wanted more control a plugin could enhance this, but it should work for now…
        Try this:
        <div class="commentnumber"><php echo $comment_id++;?></div>

        Stevarino, I just tried using your code, but found that the numbers started at 0 instead of 1 – I added this:

        $comment_id += 1;

        Just before the echo line, which fixed it – there’s almost certainly a cleverer way of dealing with it though.

        Heh… I hope so. I see so many blogs that edit the way the comments are numbered (https://photomatt.net and https://www.jinabolton.com to name only two), but I just can’t get it done in a nice way. I’ll try Stevarino’s way, and I’ll let you know…

        Well, thanks Stevarino! That works. Now I can style away :op

        Starvino’s way is a hack that gets overwritten every time WP is updated – is there another way to assign numbers to comments?

      Viewing 6 replies - 16 through 21 (of 21 total)
      • The topic ‘Create incremental number for each comment per art’ is closed to new replies.