我已經看到了各種網站使用內置的wordpress評論系統與自定義回調(生成自己的html不同,如果內置評論在WordPress中)添加數字評論在他們的網站。在wordpress中給評論添加數字
阿拉 - http://mobile.smashingmagazine.com/2013/08/12/creating-high-performance-mobile-websites/
每個註釋旁邊都有一個編號。 經過大量的搜索後,我找不到任何內置的wordpress功能。
我爲我的評論使用自定義回調。
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
}
任何人都可以給我任何想法如何編號每個評論?
不能你一個$ GLOBALS名爲$算什麼,你算你印多少評論? –