Adding numbers to comments in wordpress
I've seen various sites using the built in wordpress comment system with a
custom callback (to generate their own html different than that if the
built in comments in wordpress) adding numbers to comments on their site.
Ala -
http://mobile.smashingmagazine.com/2013/08/12/creating-high-performance-mobile-websites/
Each comment has a number beside it. After doing a whole lot of searching
I can't find any built in function of wordpress that does this.
I'm using a custom calllback for my comments.
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class(empty(
$args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php
comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="comment-author vcard">
<div class="rounded">
<?php if ($args['avatar_size'] != 0) echo
get_avatar( $comment, $args['avatar_size'] ); ?>
</div> <!-- end div rounded -->
</div> <!-- end div vcard -->
<div class="comment-meta commentmetadata">
<?php printf(__('<cite class="fn">%s</cite> <span
class="says"></span>'), get_comment_author_link()) ?>
<a href="<?php echo htmlspecialchars(
get_comment_link( $comment->comment_ID ) ) ?>">
<?php
printf( __('%1$s at %2$s'), comment_time('F j,
Y g:i a')) ?></a><?php
edit_comment_link(__('(Edit)'),' ','' );
?>
</a>
<?php if ($comment->comment_approved == '0') : ?>
<em class="comment-awaiting-moderation">
<?php _e('Your comment is awaiting
moderation.') ?>
</em>
<br />
<?php endif; ?>
</div> <!-- end div commentmetadata -->
<div class="commentsholder">
<?php comment_text() ?>
</div> <!-- end div commentsholder -->
<div class="reply">
<?php comment_reply_link(array_merge( $args,
array('add_below' => $add_below, 'depth' => $depth,
'max_depth' => $args['max_depth']))) ?>
</div> <!-- end div reply -->
<?php echo '<div style="clear:both"></div>' ?>
<?php if ( 'div' != $args['style'] ) : ?>
</div> <!-- end div commentid -->
<?php endif; ?>
<?php
}
Can anyone give me any idea how to number each comment?
No comments:
Post a Comment