Any ideas how to accomplish this?
Something like this would work, but if there are threaded comments you get the wrong number, because pages with threaded comments have actually more comments than the comments_per_page
setting:
$c_page = get_query_var('cpage');
$c_per_page = get_query_var('comments_per_page');
$number = ($c_page * $c_per_page) - $c_per_page + $current_c_index;
($current_c_index
is a global variable storing comment count for the current page loop)
Later edit:
A partial solution is to extend the Walker_Comment class, do a clone of the paged_walk() function in which you increase the counter within the $top_elements
loop. But still that doesn’t count child comments 🙁
Try the following custom Comment Walker class. The walker keep tracks for print index in a global variable named
$current_comment_print_index
; which is intialized in thepaged_walk
function.You can print global variable
$current_comment_print_index
to show the current printed comment number.I needed something similar a while ago. The following code is from my comment callback function. Inside your comment callback function, call
wpse20527_count_children();
. I assume that your$number
is a global variable.