I have a problem with the numbering of my comments when they extend to more than one page. On the new page the numbering starts from again from 1. Also, on page 2 the pingbacks/trackbacks don't appear anymore.
This is the code I'm using in comments.php:
<?php if ( have_comments() ) : ?>
<h3 class="com"><span class="com-titlu"><?php comments_number('Niciun comentariu', 'Un comentariu', '% comentarii' );?></span> la: <?php the_title(); ?></h3>
<ol class="commentlist">
<?php wp_list_comments(array(
'callback'=>'advanced_comment',
'style'=>'ol',
'type'=>'comment'
));
?>
</ol>
<?php
if ( $num = t5_count_pings() )
{
?>
<h3 id="pingbacks">
<?php printf( _n( 'One pingback', '%d pingbacks', $num, 't5_theme' ), $num ); ?>
</h3>
<ol class="pingback">
<?php wp_list_comments(array (
'type' => 'pings',
'style' => 'ul',
'callback' => 'list_pings'
));
?></ol>
<?php } ?>
And these are the functions I used in functions.php:
<?php function advanced_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div class="comment-author vcard">
<?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
<div class="comment-meta"<a href="<?php the_author_meta( 'user_url'); ?>"><?php printf(__('%s'), get_comment_author_link()) ?></a>
<span class="com-date"> a scris pe: <small><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),' ','') ?></small></span></div>
</div>
<div class="clear"></div>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em><br />
<?php endif; ?>
<div class="comment-text">
<?php comment_text() ?>
</div>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
<div class="clear"></div>
<?php } ?>
<?php add_filter('get_comments_number', 'comment_count', 0);
function comment_count( $count ) {
if ( ! is_admin() ) {
global $id;
$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
?>
<?php
/**
* Count amount of pingbacks + trackbacks for a post.
*
* @param int $post_id Post ID for comment query. Default is current post.
* @return int
*/
function t5_count_pings( $post_id = NULL )
{
$pings = 0;
$comments = FALSE;
if ( NULL !== $post_id )
{
$comments = get_comments(
array (
'post_id' => $post_id, # Note: post_ID will not work!
'status' => 'approve'
)
);
}
elseif ( ! empty ( $GLOBALS['wp_query']->comments ) )
{
$comments = $GLOBALS['wp_query']->comments;
}
if ( ! $comments )
return 0;
foreach ( $comments as $c )
if ( in_array ( $c->comment_type, array ( 'pingback', 'trackback' ) ) )
$pings += 1;
return $pings;
}
?>
Problems: 1) Trackbacks and pingbacks don't appear on each page of comments. 2) The numbering of comments starts over on each new page.
