WordPress.org

Ready to get started?Download WordPress

Forums

Comment ID (13 posts)

  1. bk
    Member
    Posted 8 years ago #

    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?

  2. oriecat
    Member
    Posted 8 years ago #

    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.

  3. bk
    Member
    Posted 8 years ago #

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

  4. oriecat
    Member
    Posted 8 years ago #

    Change the ul to an ol.

  5. bk
    Member
    Posted 8 years ago #

    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?

  6. jalenack
    Member
    Posted 8 years ago #

    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++; ?>

  7. bk
    Member
    Posted 8 years ago #

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

  8. jalenack
    Member
    Posted 8 years ago #

    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

  9. bk
    Member
    Posted 8 years ago #

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

  10. bk
    Member
    Posted 8 years ago #

    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?

  11. bk
    Member
    Posted 8 years ago #

    Anyone?

  12. Minna
    Member
    Posted 8 years ago #

    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

  13. bk
    Member
    Posted 8 years ago #

    Thanks a lot Minna!!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.