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.
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。