0
A
回答
3
有,说明如何从过去30天内列出的职位上抄本一个例子: http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters
你要适应它,以满足您的需求,例如(未测试):
// Create a new filtering function that will add our where clause to the query
function filter_where($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-1 year')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
$query = new WP_Query($query_string);
remove_filter('posts_where', 'filter_where');
-1
<?php
$date1yrback = date('Y-m-d',strtotime(date("Y-m-d", mktime()) . " - 365 day")); // Find Date 1 year back
$countp = 0;
if (have_posts()) : while (have_posts()) : the_post();
$my_date = the_date('Y-m-d', FALSE); //Find Post Date
if($my_date > $date1yrback) //Check if Post date is greater than date year back
{
echo "<h1>".the_title()."</h2>";
echo "<p>".the_content()."</p>";
$countp++; //Increment counter as post in above criteria is found
}
endwhile; endif;
if($countp == 0)
{
?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php
}
?>
相关问题
- 1. WP查询分类帖子
- 2. wordpress - WP查询自定义类型/税不显示帖子
- 3. 自定义帖子类型“property”(wp-property plugin)查询问题
- 4. 如何在查询中只显示特定数量的帖子?
- 5. WordPress的SQL查询帮助(列出来自特定类别的帖子)
- 6. MongoDB:仅查询特定子文档
- 7. 无法查看WP主页中的自定义帖子类型帖子
- 8. 查询帖子自定义字段:ACF中继器内的检查列表
- 9. 在wordpress中查询帖子
- 10. WP-API在特定日期后获取帖子
- 11. 基于wordpress中的自定义字段查询帖子
- 12. 多值查询自定义字段WP
- 13. 排除从WP-饲料特定的帖子
- 14. WP Alchemy Meta Box - 获取特定帖子的Meta Box值
- 15. 通过WP Rest API创建自定义字段的帖子
- 16. 查询查找帖子没有自定义字段
- 17. WP与查询和帖子类型冲突
- 18. WP自定义帖子类型UI
- 19. 如何查询自定义字段的wordpress帖子
- 20. 使用多个自定义字段的查询帖子
- 21. 查询帖子使用帖子ID
- 22. 添加专栏WordPress的帖子(特别是WP电子商务)
- 23. 如何使用自定义帖子类型列出来自类别的帖子? (WP)
- 24. 仅显示特定类别的自定义帖子类型
- 25. 如何在特定序列中列出mysql查询结果?
- 26. 查询仅在特定时间发生的交易
- 27. WP JSON REST API(Ryan McCue)如何用'AND'关系查询特定元数据的帖子?
- 28. 永久链接列出特定post_type的所有帖子
- 29. 查找与标签有关的帖子与mysql中的一个特定帖子
- 30. WordPress的帖子查询
你不需要的插件,看看这里:http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters – soju
感谢这个作品 – Krunal