• Resolved Doodlebee

    (@doodlebee)


    So, I’ve taken a different stance with my comments lists on my new theme, but I’m having just a *teensy* issue here. What I’m doing is chucking the <ul><li> stuff for listing comments people have placed. I’m doing a more stylistic version instead, where the actual comment number is set as a kind of background to the comment instead.

    You can see it in action here: scroll to the bottom and you can see the two comments, and how the background has the numbers in it.

    Now, the thing is, if you notice in that post that the numbers are actually “3” and “4” – not “1” and “2”. If you look through other posts it’s the same – it appears that it’s taking the actual comment ID and putting that in the background – so it’s showing the comment ID for the whole *site*, not just for the post at hand.

    Of course, I look back at my code and smack myself in the head, because that’s what I *told* it to do. Duh. My code looks like this:

    <?php foreach ($comments as $comment) : ?>
    
    <div class="comment<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
    <div class="number"><?php echo comment_ID(); ?></div>

    Now, the “number” div is what holds the actual number you see in the background. I’m using the “comment_ID” – which is why it’s showing the numbering system the way it is. Is there a way to change that so it shows the correct numbers for each *post* – not for the site on the whole?

    Hopefully that makes sense!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Neat look, BTW. I don’t like the pink (I’m more of a purple fan, personally), but the number in the background like that is damn cool.

    Anyway, here’s your fixed code:

    <?php
    $my_comment_count = 1;
    foreach ($comments as $comment) : ?>
    <div class="comment<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
    <div class="number"><?php echo $my_comment_count; $my_comment_count++; ?></div>
    Thread Starter Doodlebee

    (@doodlebee)

    Thank you Otto! Works like a charm. (And no, I’m not a “pink” person either – but sometimes certain shades will hit me right. It’s rare though – I’m more of a “green” girl!)

    Thanks again 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Numbering Comments’ is closed to new replies.