我想知道是否有办法通过创建日期限制 wp_query 的结果?我只想收到不超过三天的所有帖子。
最佳答案
您可以使用 WP_Query 的日期参数来完成此操作。
http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters
$args = array(
'date_query' => array(
array(
'after' => $threeDaysAgo,
'inclusive' => true,
),
),
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
After 可以采用 strtotime() 兼容的字符串。 http://php.net/manual/en/function.strtotime.php
关于php - WordPress 过去三天的所有帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25119950/