Get threaded comments number

I’m using Greg’s Threaded Comment Numbering plugin to number the comments. Actually I’m displaying a number beside of each parent comment (no threaded comments numbers). I have 2 problems that I have already tried to solve, but without results:

Example:

COMMENT 1

————1.1

————1.2

————1.3

total threaded comments = 3

COMMENT 2

————2.1

————2.2

total threaded comments = 2

etc…..

I am already using the code below to get the total number of parents. I can also get the children but it is the total, I need to display the number of each comment children as in the example

$number_of_parents = c_parent_comment_counter($post->ID);
$number_of_children = $post->comment_count - $number_of_parents;

Thanks!

EDIT: as requested here is the wp_list_comments callback function. Sorry for the mess, I am not a programmer, will clean the code when the work is finished 🙂

## Function: Basic Callback Function From WP Codex (http://codex.wordpress.org/Template_Tags/wp_list_comments), January 2009
function gtcn_basic_callback($comment, $args, $depth) {
// no changes here except that we have added in the call to gtcn_comment_numbering
   $GLOBALS['comment'] = $comment; 


   ?>
   <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
   <?php   if( empty( $comment->comment_parent ) ) { //if the comment does not have a parent, then it is L1?>
            <div class="linguetta-posizione"><?php  echo gtcn_comment_numbering($comment->comment_ID, $args); 

            ?></div>        
                <?php   }
         ?>

     <div id="comment-<?php comment_ID(); ?>">
      <div class="comment-author vcard">
        <div class="comment-barra-user">

            <div class="comment-avatar">
            <?php if( empty( $comment->comment_parent ) ) { ?><?php echo get_avatar($comment,$size='60'); ?><?php } else { ?><?php echo get_avatar($comment,$size='30'); ?><?php } ?></div>
            <div class="comment-username"><?php printf(('<cite class="fn">%s</cite> '), get_comment_author_link()) ?><br class="clear"/>
                <?php if( empty( $comment->comment_parent ) ) { ?><div id="comment-container-points">
                    <div class="comment-points"><img src="<?php bloginfo('template_url'); ?>/images/ico-points.png" /><a>3333</a></div><div class="comment-level"><img src="<?php bloginfo('template_url'); ?>/images/ico-level.png" /><a>livello</a></div>
                </div>      <?php } else { ?><?php } ?>         
            </div>
            <?php if ( is_user_logged_in() ) { if( empty( $comment->comment_parent ) ) {?>
            <div class="comment-votazione"><h2>Vota la risposta:</h2>

            <?php    { //if the comment does not have a parent, then it is L1
                    if(function_exists(ckrating_display_karma)) { ckrating_display_karma(); }
                    }
         ?> </div>
            <?php }} else { 

                if( empty( $comment->comment_parent ) ) { ?>
                <div class="comment-votazione"><h2>Registrati per votare</h2>

                 </div>
            <?php }}  ?> 


        </div><!-- end BARRA USER -->

    <br class="clear"/>

      </div>
      <?php if ($comment->comment_approved == '0') : ?>
         <em><?php _e('Your comment is awaiting moderation.') ?></em>
         <br />
      <?php endif; ?>


      <?php comment_text() ?>

      <div class="reply">
         <?php comment_reply_link(array_merge( $args, array('reply_text' => 'COMMENTA LA RISPOSTA', 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
      </div><div class="comment-meta commentmetadata"><?php if( empty( $comment->comment_parent ) ) { ?>Risposta inserita<?php } else { ?> Commento inserito <?php } ?>
            <?php echo time_ago_comment(); ?><?php edit_comment_link(('- modifica'),'  ','') ?></div>

     </div></li>

<?php
} // end basic callback function

Related posts

Leave a Reply

1 comment

  1. // inside your callback function:
    static $ancestors = null;
    $parent = (int) $comment->comment_parent;
    
    // Modify INITIAL VALUE here:
    $init_val = (int) 1;
    
    $is_child = false;
    if ( $parent > (int) 0 )
    {
        $is_child = true;
        $ancestors[] = $parent;
        $child_counter = count( $ancestors ) + $init_val;
    }
    /*
     * Only needed in case you want to reset the counter if the current comment has no children
    else
    {
        $ancestors = $child_counter = null;
    }
    */
    
    // This shows the number of the current reply counter
    if ( $is_child ) 
        printf( __( 'This is the child number: ', TEXTDOMAIN ), $child_counter );