Numbered Comments

  • thajekku

    #277

    How do I number my comments?? Everything I have found to help says something like this

    #Locate the comments.php file.

    # Locate the code that starts the comment loop. It will look something like this:

    <?php if ( $comments ) : ?>

    # Place this code immediately above the code in Step 3:

    <?php $i = 0; ?>

    # Now locate the code that looks like this:

    <?php foreach ($comments as $comment) : ?>

    # Placed this code immediately below the code in Step 5:

    <?php $i++; ?>

    # Now use this code where you want to display your comment numbers:

    <span class=”count”>

    <?php echo $i; ?>

    </span>

    # Click Save.

    # Now go to your stylesheet (style.css) and place this code anywhere on the stylesheet (probably best placed in the comments section):

    .count {

    float:right;

    padding: 10px;

    font-size:18px;

    color:#000000;

    }

    But there is no <?php if ( $comments ) : ?> or <?php foreach ($comments as $comment) : ?> . I tried a plugin too but it didn’t work.

    *I would also like to change the text where it says 6 comments to {6 comments… read them below or add one} where “add one” is a link that jumps down to the comment form.

    Here’s an example – http://www.tobethode.com/2010/12/dear-2010.html

    I know I’m driving you crazy! 🙂 I REALLY appreciate your help and quick response!!

    Marvelous Mommy

    #11895

    Ok I figured out how to change the text where it says 6 comments right above the start of the comments. And when you click on add one, it jumps to the form!!

    Now I just need numbers…

    Admin

    Syahir Hakim

    #11896

    The theme uses the wp_list_comments() function to automatically list all the comments, as required by the theme guidelines in WP.org. The function then uses the graphene_comment() function inside functions.php to format the comments.

    I’m not so sure about numbering the comments when this function is being used. I’ll email the Theme Reviewers about this and see if they have any suggestion.

    Marvelous Mommy

    #11897

    I tried using Greg’s Threaded Comment Numbering Plugin

    http://counsellingresource.com/features/2009/01/27/threaded-comment-numbering-plugin-for-wordpress/

    It says…

    *Advanced Usage: Calling WordPress Plugin Functions Directly*

    If your theme already uses a custom callback function, it probably lives in functions.php, and you will see the name of your callback function specified in the call to wp_list_comments() in your comments.php file. You can modify the callback function to incorporate comment numbering wherever you would like it to appear by just adding the following: <?php echo gtcn_comment_numbering($comment->comment_ID, $args); ?>.

    And I tried doing that but I wasn’t really sure where to put it and when I did it I crashed my whole site. 🙁 I put it on line 421 in the functions.php

    Admin

    Syahir Hakim

    #11898

    You can put the code anywhere after this line:

    <li id="comment-<?php comment_ID(); ?>" <?php comment_class('clearfix'); ?>>

    in the graphene_comment function in functions.php.

    The more elegant implementation would be to use any of the action hooks available within the graphene_comment function from within your child theme, so that you won’t lose the modification when you update the theme.

    Marvelous Mommy

    #11899

    I put <?php echo gtcn_comment_numbering($comment->comment_ID, $args); ?> after <li id=”comment-<?php comment_ID(); ?>” <?php comment_class(‘clearfix’); ?>> and it didn’t work.

    Was I supposed to change the code some first??

    Admin

    Syahir Hakim

    #11900

    Remove the echo, so that the code to be included looks just like this:

    <?php gtcn_comment_numbering($comment->comment_ID, $args); ?>

    Marvelous Mommy

    #11901

    What?? Sorry you’ve been so helpful but I’m confused. It’s that what I posted? Remove echo so it looks like this??

    <?php gtcn_comment_numbering($comment->comment_ID, $args); ?>

    So all together it would be…

    if (!function_exists(‘graphene_comment’)) :

    function graphene_comment($comment, $args, $depth) {

    $GLOBALS = $comment; ?>

    <li id=”comment-<?php comment_ID(); ?>” <?php comment_class(‘clearfix’); ?>>

    <?php gtcn_comment_numbering($comment->comment_ID, $args); ?>

    Just tried that. It didn’t work. It says – Fatal error: Call to undefined function gtcn_comment_numbering() in /home/marvel8/public_html/wp-content/themes/graphene/functions.php on line 427

    Admin

    Syahir Hakim

    #11902

    Ugh..sorry, my last post should have not contained that echo bit in the code. Edited.

    That call to undefined function error is usually caused by the plugin not being activated. I just tested your code on my development server and it works.

    Marvelous Mommy

    #11903

    Oh gosh! I guess that was it. I activated the plugin and re-added the code and it worked! Any idea how I move the comment numbers to the right instead of the left??? 🙂

Viewing 10 posts - 1 through 10 (of 16 total)

You must be logged in to reply to this topic.