在原来的MovableType(MT)中,留言的排列顺序可以通过提供的Option来设定。通常来讲,一般要求新的留言在前面,旧的留言就往后排。
转到WordPress(WP)之后,发现这里默认的留言顺序是按照时间顺序:先发的在上面。这样不符合我的习惯,于是想要改一改。 WP的留言功能是用wp-comments.php这个文件来实现的。对于留言的逐个显示使用了foreach命令,而foreach命令是对数组逐行操作,使用方法里是没有对数组倒着操作的功能的。那么,就要从数组的结构下手。数组是从数据库中读出来的,用到的是如下命令:
$comments = $wpdb->get_results(”SELECT * FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = ‘1′ ORDER BY comment_date”);
这里有个ORDER BY comment_date,也就是说按照时间顺序排列。找到相关的数据库操作命令,发现只要加一个DESC,就可以实现降序排列的结果。于是:” ORDER BY comment_date “就变成” ORDER BY comment_date DESC “。修改之后更新服务器上的wp-comments.php文件。这样,留言就变成降序排列了。
2 Comments so far
Leave a comment
Fields in bold are required. Email addresses are never published or distributed.
Some HTML code is allowed:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
URIs must be fully qualified (eg: http://www.dupola.com) and all tags must be properly closed.
Line breaks and paragraphs are automatically converted.
Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.



wordpress默认的显示页面,是按照发布的先后顺序来排列的。
往往并不符合实际需要。所以,我找了一个可以调整wordpress 页面顺序的插件:my page order
http://geekyweekly.com/mypageorder
下载安装在我的网站( http://www.18ie.com/wordpress ),在登陆进入wordpress,激活my page order,
然后,可以方便地调整页面的顺序(page order)。
值得注意的是,需要在 wordpress/wp-content/themes/你的风格/sidebar.php里,进行修改。
在 wp_list_pages 的参数里,加入 & sort_column=menu_order
可以参考:
http://www.18ie.com/wordpress/?p=53
http://www.oaso.cn/blog/wordpress/2006/10/24/78.html
什么东西,看不懂?偶比较菜!