WordPress下的默認(rèn)排序是按照發(fā)布時間排序,但有時候,如果按修改時間排序來的比較合理,特別是有一些資料代碼需要更改修正的時候。
下面,就說說已首頁最新文章列表為例,修改成按修改時間排序。
wordpress的排序方式
- orderby=date 按發(fā)布日期排序
- orderby=modified 按修改時間排序
- orderby=ID 按文章ID排序
- orderby=comment_count 按評論最多排序
- orderby=title 按標(biāo)題排序
- orderby=rand 隨機(jī)排序
用法
1、在首頁的PHP文件中搜索
<?php while ( have_posts() ) : the_post(); ?>
2、在while
前面加上下面這段代碼
$args = array(
'showposts' => 10,
'orderby' => modified,
);
query_posts($args);
然后保存,即可完成最新文章按修改時間排序。
]]>