WordPress前台展示最近更新过的文章列表,可以将下面代码添加到functions文件中
function recently_updated_posts($num=10,$days=7) {
//10为展示文章数量,7指7天内发表的文章除外,具体使用的时候可以根据自己的情况修改这两个参数。
if( !$recently_updated_posts = get_option('recently_updated_posts') ) {
query_posts('post_status=publish&orderby=modified&posts_per_page=-1');
$i=0;
while ( have_posts() && $i<$num ) : the_post();
if (current_time('timestamp') - get_the_time('U') > 60*60*24*$days) {
$i++;
$the_title_value=get_the_title();
$recently_updated_posts.='» 修改时间: ' .get_the_modified_time('Y.m.d G:i').'
前台输出:
Recently Updated Posts


