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