comments.php
<?php if ( have_comments() ) : ?>或是<?php if ( $comments ) : ?>
<?php global $comment_ids; $comment_ids = array();
foreach ( $comments as $comment ) {
if (get_comment_type() == "comment") {
$comment_ids[get_comment_id()] = ++$comment_i;}
} ?>
<span class="floor"><?php global $comment_ids; $comment_floor = $comment_ids[get_comment_id()]; echo $comment_floor.'楼'; ?></span>
-----------------------------------
只在WP主评论加上楼层号的方法via:http://zww.me/archives/25161/
//主评论计数器初始化 begin - by zwwooooo
global $commentcount;
if(!$commentcount) { //初始化楼层计数器
$page = get_query_var('cpage')-1;
$cpp=get_option('comments_per_page');//获取每页评论数
$commentcount = $cpp * $page;
}
//主评论计数器初始化 end - by zwwooooo
<div class="floor"><!-- 主评论楼层号 by zwwooooo -->
<?php if(!$parent_id = $comment->comment_parent) {printf('#%1$s', ++$commentcount);} ?><!-- 当前页每个主评论自动+1 -->
</div>
ol.commentlist li div.floor{position:absolute;top:0;right:0;}
学习了
这么混乱的字符显示,悲催~