[英]Wordpress Query by custom date filed
Can someone show me how to do this, I have a query I'm using to display custom posts and using WP Facet for the query, by a custom field date, I got this far to order the posts by date in Ascending order, but the last thing I want to do is only show the posts that equal today's date or future dates;有人可以告诉我如何执行此操作吗,我有一个查询,用于显示自定义帖子并使用 WP Facet 进行查询,按自定义字段日期,我已经到了按日期按升序排序帖子,但是我最不想做的就是只显示等于今天或未来日期的帖子;
I've tried a few things but no joy as of yet, thanks我已经尝试了一些东西,但目前还没有快乐,谢谢
<?php
return array(
'post_type' => 'event',
'post_status' => 'publish',
'posts_per_page' => 15,
'orderby' => 'event_date',
'order' => 'ASC',
'sort_custom' => true,
'meta_query' => array(
array(
'key' => 'event_date',
),
)
if this helps anyone - i worked it out:如果这对任何人都有帮助-我解决了:
<?php
return array(
'post_type' => 'event',
'post_status' => 'publish',
'meta_key' => 'event_date',
'posts_per_page' => 15,
'orderby' => 'event_date',
'order' => 'ASC',
'sort_custom' => true,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'event_date',
'compare' => '>=',
'value' => date("Y-m-d"),
'type' => 'DATE'
),
)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.