I have defined a walker in function.php to display comments in a certain way. I use the following code:
function speld_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<?php
global $comment_count;
$comment_count++;
?>
<!-- <?php echo $comment_count; ?> -->
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-author_pic">
<?php echo get_avatar($comment,$size='48',$default='http://www.speld.nl/wp-content/themes/speld5/images/avatar.png' ); ?>
<p class="comment_number"><?php echo $comment_count; ?></p>
</div>
<div class="comment_text">
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Een moment geduld, uw reactie wordt beoordeeld door de Speld Waarheidscommissie.') ?></em>
<?php endif; ?>
<div class="comment-meta commentmetadata">
<?php printf(__('%s'), get_comment_author_link()) ?> •
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s, %2$s'), get_comment_date(), get_comment_time()) ?></a>
<?php // we want to add 'Zie profiel' here.. comment_author_link() ?>
</div>
<?php comment_text() ?>
<div class="comment_tools">
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'reply_text'=>'Reageer', 'max_depth' => $args['max_depth']))) ?>
</div>
</div>
</div>
I’ve also enabled reacting to a comment (1 level deep).
The problem is in the comment_count variable. Whenever somebody replies to a comment, the numbering for all comments below the reply shifts one number down. I’d like to prevent that from happening.
Is it possible to make an if statement in the walker that allows reactions to a comment to not contain the comment_count variable? Any help would be greatly appreciated!
Just use the $depth arg: