因為大多主題的留言薄都是將最新留言放在最下面,所以很不習慣,通過小修小改即可把留言順序按照最新留言放在上面了——即實現倒序。
修改 comments.php 里面的評論順序
1 2 3 4 | //也很簡單,只需要在文件中替換一處代碼: <?php foreach ($comments as $comment) : ?> //替換成: <?php foreach (array_reverse($comments) as $comment) : ?> |
如果有評論編號,做如下要改
通過上面的修改你的留言順序應該倒過來了,如果有序號的話,還須把序號倒過來才算完美。不過有不少的模板主題的編號代碼都不一樣,有$iCommentCount或$iCommentnumber,我們僅用$iCommentCount做例子:
1 2 3 4 5 6 7 | $iCommentCount = 0; //... <?php $iCommentCount++; echo($iCommentCount); ?> //需要改成初始值為評論總數,輸出一次自減一次,循環: $iCommentCount = get_comments_number(); //... <?php echo($iCommentCount); $iCommentCount--; ?> |