在Wordpress的Genesis框架中按日期范围过滤帖子

在Wordpress的Genesis框架中按日期范围过滤帖子,wordpress,Wordpress,这个问题只适用于Genesis框架 我有一个类别叫做“新闻”。在我的“新闻”类别页面上,我只想显示过去30天内发表的文章 以下是我开始使用的代码: <?php remove_action('genesis_loop', 'genesis_do_loop'); add_action('genesis_loop', 'pm_recent_news_loop'); function pm_last_name_loop() { global $query_args; $args = (arra

这个问题只适用于Genesis框架

我有一个类别叫做“新闻”。在我的“新闻”类别页面上,我只想显示过去30天内发表的文章

以下是我开始使用的代码:

<?php

remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'pm_recent_news_loop');

function pm_last_name_loop() {
global $query_args;
$args = (array(
   //????
));

genesis_custom_loop( wp_parse_args($query_args, $args) );

}
genesis();

尝试添加一个过滤器,使用一些SQL语句

filter_daterange($where='') {
$where .= " AND post_date >= '".date('Y-m-d H:i:s', strtotime('-30 days'))."' AND post_date <= '".date('Y-m-d H:i:s')."'";
return $where;
}

谢谢,这是我在之前没有收到回复后最终确定的方法。这个答案总结得很好。很高兴它帮助了你。我不确定这是否适合《创世纪》的主题。
add_filter( 'posts_where', 'filter_daterange' );
genesis_custom_loop( wp_parse_args($query_args, $args) );
remove_filter( 'posts_where', 'filter_daterange' );