我有一个自定义查询,我正在按自定义字段筛选事件:事件月。我简单地过滤那些没有月号=截止日期(“n”)的事件;
这是一个非常好的小查询,但我需要按另一个自定义字段event\\u date排序。
我是否需要自定义函数或其他什么来完成此操作。我只想排序方式=>event\\u date
但我目前正在使用事件月进行查询。
<?php
$event_query = new WP_Query(
array(
\'post_type\' => \'event\', // only query events
\'meta_key\' => \'event-month\', // load up the event_date meta
\'order_by\' => \'\',
\'order\' => \'asc\', // ascending, so earlier events first
\'meta_query\' => array(
array( // restrict posts based on meta values
\'key\' => \'event-month\', // which meta to query
\'value\' => date("n"), // value for comparison
\'compare\' => \'=\', // method of comparison
\'type\' => \'NUMERIC\' // datatype, we don\'t want to compare the string values
) // meta_query is an array of query ites
) // end meta_query array
) // end array
); // close WP_Query constructor call
?>