Get threaded comments number

// 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 );

Leave a Comment