给wordpress添加楼的显示方法
1、在主题文件的comments.php中找到或是,在后面加上如下代码:
1 | <?php global $comment_ids; $comment_ids = array(); |
1 | foreach ( $comments as $comment ) { |
1 | if (get_comment_type() == "comment") { |
1 | $comment_ids[get_comment_id()] = ++$comment_i;} |
1 | } ?> |
2、在显示评论时提取楼号: 在主题的function.php代码中找到评论的代码,一般带有comment 的都是那点了,找一个显示合适的位置,自己可以测试,看显示的位置合不合适!插入如下代码: <特别提醒,要注意编码问题,不然你的主页会显示不正常的哟
1 | <span class="floor"><?php global $comment_ids; |
1 | $comment_floor = $comment_ids[get_comment_id()]; |
1 | echo $comment_floor.'楼'; ?></span> |
好了就这么简单,呵呵!