Php 获取所有超过15分钟的WP帖子

Php 获取所有超过15分钟的WP帖子,php,mysql,wordpress,Php,Mysql,Wordpress,我想过滤WP_查询,以检索所有具有超过15分钟的特定状态的商业订单(post_type=shop_order) 也就是说,所有最后一次修改的帖子(现在-15分钟)//希望我清楚 低于我所尝试的 function filter_where($where = '') { //posts in the last 15 minutes $where .= " AND post_modified > '" . date('Y-m-d', strtoti

我想过滤WP_查询,以检索所有具有超过15分钟的特定状态的商业订单
(post_type=shop_order)

也就是说,所有最后一次修改的帖子(现在-15分钟)//希望我清楚

低于我所尝试的

 function filter_where($where = '') {
            //posts in the last 15 minutes
           $where .= " AND post_modified > '" . date('Y-m-d', strtotime('INTERVAL 15 MINUTE')) . "'";
            return $where;
        }
        add_filter('posts_where', 'filter_where');

 $args = array(
    'post_type'         => 'shop_order',
    'post_status'       => 'publish',
            'posts_per_page' => 10,
    'tax_query' => array(
                array(
                    'taxonomy' => 'shop_order_status',
                    'field' => 'slug',
                    'terms' => array('completed')
                )
            )
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();

    $order_id = $loop->post->ID;


    $order = new WC_Order($order_id);
print_r("<pre>");
        print_r($order);
      print_r("</pre>");
 endwhile;  
函数过滤器\u其中($where=''){
//过去15分钟的帖子
$where.=“和post_modified>”。日期('Y-m-d',标准时间('INTERVAL 15分钟'))。“;
返回$where;
}
添加_filter('posts_where','filter_where');
$args=数组(
“post_type”=>“shop_order”,
“发布状态”=>“发布”,
“每页帖子数”=>10,
“tax_query”=>数组(
排列(
“分类法”=>“车间订单状态”,
'字段'=>'段塞',
'terms'=>数组('completed')
)
)
);
$loop=新的WP_查询($args);
而($loop->have_posts()):$loop->the_post();
$order\u id=$loop->post->id;
$order=新WC\U订单($order\U id);
印刷品(“”);
打印(订单);
印刷品(“”);
结束时;
然而,返回所有记录,似乎必须修改$where查询,我如何才能实现这一点?

尝试将日期('Y-m-d',strottime('INTERVAL 15分钟')更改为日期('Y-m-d H:i:s',strottime('-15分钟'))

尝试将日期('Y-m-d',标准时间('15分钟间隔')更改为日期('Y-m-d H:i:s',标准时间('-15分钟'))


您是否需要在其中筛选
帖子?你就不能用它吗?在您的情况下,特别是在
之前


我现在无法测试,因此无法验证它是否有效。如果要修改归档文件,则必须通过调整查询,而不是创建新查询

您需要过滤
帖子吗?你就不能用它吗?在您的情况下,特别是在
之前


我现在无法测试,因此无法验证它是否有效。如果要修改归档文件,则必须通过调整查询,而不是创建新查询

您能告诉我们您在哪里声明
$loop
?已更新,就在while循环的上方您能告诉我们您在哪里声明
$loop
?已更新,就在while循环的上方吗
function filter_where($where = ''){
            //posts in the last 15 minutes
   $where .= " AND post_modified > '" . date('Y-m-d H:i:s', strtotime('-15 minutes')) . "'";
   return $where;
}
add_filter('posts_where', 'filter_where');
$args = array(
    'date_query' => array(
        array(
            'before'    => '15 minutes ago'
            'inclusive' => true,
        ),
    ),
    'posts_per_page' => -1,
);
$query = new WP_Query( $args );