DUX 主题小工具中“聚合文章”默认调取的是所有时间的文章,根据个人需要修改了下只调取最近一段时间(一年内的)文章。此方法兼容版本 dux v6.1

QQ截图20190316202450.png

QQ截图20190316202345.png
文件路径:/wp-content/themes/dux/widgets/widget-posts.php

修改前源代码:

function dtheme_posts_list($orderby,$limit,$cat,$img,$comn) {
 $args = array(
  'cat'    => $cat,
  'order'   => 'DESC',
  'showposts'  => $limit,
  'ignore_sticky_posts' => 1
 );

修改后源代码:

function dtheme_posts_list($orderby,$limit,$cat,$img,$comn) {
 $args = array(
  'cat'    => $cat,
  'order'   => 'DESC',
  'showposts'  => $limit,
  'ignore_sticky_posts' => 1,
  'date_query' => array(array('column' => 'post_date_gmt',
   'after' => '1 year ago',))
 );