DUX 1.4 模板中“D-聚合文章”默认调取的是所有时间的文章,根据个人需要修改了下只调取最近一段时间文章。

文件路径:/wp-content/themes/dux/widgets/widget-posts.php

源代码:

function dtheme_posts_list($orderby,$limit,$cat,$img) {
	$args = array(
		'order'            => 'DESC',
		'cat'              => $cat,
		'orderby'          => $orderby,
		'showposts'        => $limit,
		'category__not_in' => array(211),
		'ignore_sticky_posts' => 1
	);
	query_posts($args);
	while (have_posts()) : the_post(); 
?>

 

修改代码:

function dtheme_posts_list($orderby,$limit,$cat,$img) {
	$args = array(
		'order'            => 'DESC',
		'cat'              => $cat,
		'orderby'          => $orderby,
		'showposts'        => $limit,
		'category__not_in' => array(211),
		'ignore_sticky_posts' => 1,
		'date_query' => array(array('column' => 'post_date_gmt',
		            'after' => '1 year ago',))
	);
	$recentPosts = new WP_Query($args);
	while ($recentPosts->have_posts()) : $recentPosts->the_post();
?>

上面的 post_date_gmt 是指文章的发布时间,可换成 post_modified_gmt 为文章的最后更新时间。

‘after’ => ‘1 year ago‘ 一年内发布的文章,如果要改成1个月内的‘1 month ago

已改好的文件,直接上传覆盖源文件即可

Sorry, only those who have replied to this post could see the hidden contents.

下载面板

恭喜,此资源为免费资源,请先
  • 未登录无法下载,登录可获得更多免费资源。
  • 赞助资源,发现余额不足时,根据提示付款操作即可。充值点击这里!