Support » Themes and Templates » Comment ID

  • php comment_ID()
    When I add that, it shows me the total number of comment. I’m trying to make when people leave a comment on a new posts, it starts from 1, 2, and so on.

    How to do that?

Viewing 12 replies - 1 through 12 (of 12 total)
  • You just want an ordered list of the comments? Or you want to actually have the comment ID changed? I don’t think you can do the latter, because the comment ID comes from the database and each ID has to be unique.

    Yeah, sure. Ordered list of comments would work. Is there a way to do it?

    Change the ul to an ol.

    In what though? The comment.php file? o_O
    Take this site for example. The number of the right side of the comments. Is that what ol is for? Or do you use something else?

    You won’t be able to pull that off with an ordered list. You’ll need a simple count on the loop. To clarify, the loop is foreach ($comments as $comment) Edits in comments.php of your template file:

    Before this code:
    <?php foreach ($comments as $comment) : ?>
    Add this:
    <?php $com_count = 1; ?>
    Then, inside the loop, where you want the number to appear, add this:
    <?php echo $com_count++; ?>

    Do I have to create a file? Like theloop.php or something?

    no, go to your theme directory (/wp-content/themes/*****YOURTHEME****/) and open comments.php . This is the template file that displays the comments. You should find the stuff above somewhere in the middle. The loop is just a name for the foreach() statement that is used to display comments

    Can’t seem to position it. Could you please check my comment page.

    And how can I increase the size of them. If I put like h2 or h3, a big gap is shown then. I know this has to do with CSS, but how exactly would I do it?


    You’ll need to wrap it (the <?php echo … ?>) in a <span>, or <div> actually, and give it a class. For example <div class=”comment_number”><?php echo $com_count++; ?></div>. And then you can modify it in the CSS (float it left/right, change size etc.). Maybe a span would float too. I don’t know 🙂

    I have something like
    div.comment_number {
    font-size: 250%;
    float: right;

    in the css

    Thanks a lot Minna!!

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