為留言增加序列號

  讲一下如何在留言部分增加数字序列,以WordPress的Default模版为例:
修改comment.php

  1. 找到<ol class=”commentlist”>,在这句下面添加<?php $relax_comment_count=1; ?>
  2. 一般来说这句下面会有一段<li></li>的语句,在这段语句下面添加<?php $relax_comment_count++; ?>
  3. 上面说到的那句<li></li>中可以找到一句<?php comment_text() ?>,在此句上方添加<div class=”commentcount”><?php echo $relax_comment_count; ?></div>

最终像是这个样子:


接下来就是用css来调整一下commentcount的表现形式,在style.css里增加类似下面的内容:
.commentcount {
font-family: Georgia,sans-serif;
font-size: 24px;
font-weight: bold;
color: #e0e0d0;
float: right;
}

  文章到此完毕,其他模版基本也是一样的,大家自己推敲推敲。

Technorati Tags: ,

7 Responses to “為留言增加序列號”

Leave a Reply to 精品网络收藏

Note: Commenter is allowed to use '@User+blank' to automatically notify your reply to other commenter. e.g, if ABC is one of commenter of this post, then write '@ABC '(exclude ') will automatically send your comment to ABC. Using '@all ' to notify all previous commenters. Be sure that the value of User should exactly match with commenter's name (case sensitive).