WordPress.org

Ready to get started?Download WordPress

Forums

Number on comment (6 posts)

  1. hulemanden
    Member
    Posted 7 years ago #

    Hello.

    I'm pretty new to the world of WP, and i'm searcing for a plugin or something, that will give each comment a number, so when I answer on a comment, i can refer to that number.'

    Hope I have explained it good enough - I'n not used to write in English ;-)

    Kent

  2. moshu
    Member
    Posted 7 years ago #

    In the theme you are using every comment has its own permalink: the date of the comment is the link to that specific comment.

    If you just want to have the comments numbered below every post, like 1. 2. 3 etc... you have to:
    a) use an ordered list to display them
    b) find a theme that already does it for you

  3. hulemanden
    Member
    Posted 7 years ago #

    Thanks - Yep, just like that 1,2,3...

    Sorry for asking - but how do I use an ordered list to display them? can I do that in K2 - my current theme.

  4. moshu
    Member
    Posted 7 years ago #

    You probably can, although I am not familiar with that theme.
    You may try your luck here, and wait until somebody replies or you can go and ask for specific help in the forum of the theme you are using: http://getk2.com/forum/index.php

  5. hulemanden
    Member
    Posted 7 years ago #

    Ill try that - thanks a lot.

  6. lelion
    Member
    Posted 7 years ago #

    Other option, you can number the comments using two lines of PHP, I recently did so for my new WP website:)

    In file comments.php of your theme, find this code:

    /* This variable is for alternating comment background */
    $oddcomment = 'alt';
    ?>

    and add this, so the code becomes:

    /* This variable is for alternating comment background */
    $oddcomment = 'alt';
    $commentcount=1; // added line!
    ?>

    After that, simply decide, where you want your comment number to be showed:

    1) Let's say, you want them shown on the line which says smth. like this:
    "January 15th, 2007 at 12:15"
    and it should become smth. like this:
    "Comment #3, posted on January 15th, 2007 at 12:15"

    To do this, find in comments.php:

    <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time('H:i') ?></a> <?php edit_comment_link('e','',''); ?></small>

    (NOTE: Your code could be different according to theme used. Look for something similar!)

    Then, add

    <?php echo $commentcount++; ?>

    where you would like the number to appear - in this case, it could be done like this:

    <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title="">Comment #<?php echo $commentcount++; ?>, posted on <?php comment_date('F jS, Y') ?> at <?php comment_time('H:i') ?></a> <?php edit_comment_link('e','',''); ?></small>

    Easy:)

    2) If you want them to appear like big number with faint color somewhere at the top right of each comment (you've sen lots of examples of this sort), then you need to make two modifications:

    a) In your comments.php file, add a

    <span class="comment-number"><?php echo $commentcount++; ?></span>

    before the code

    <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?> etc. etc.

    b) In your style.css file for your theme (search for a .CSS file in your theme dir), first, add the following to the class concerning all LIs for the class "commentlist":

    .commentlist li {
    /*other styles be here*/
    position: relative; /* this is added! */
    }

    After that, add the following somewhere in the same CSS file:

    .comment-number {
    position: absolute; /* this and next two lines place comment number at top right of each comment */
    top: 0;
    right: 0;
    color: #CCC; /* any color here */
    font-size: 30px; /* any font size */
    font-family: Georgia, "Times New Roman", serif; /* any font-family here */
    }

    That's it! :-)

Topic Closed

This topic has been closed to new replies.

About this Topic