我正在尝试按ACF日期选择器自定义字段进行排序,但是未排序。我根据使用哪种形式的输入来构建查询,但是我也尝试过仅对查询进行硬编码,但是没有运气。我正在通过ajax提交此文件以在页面上显示结果。
我将订单从DESC更改为ASC,根本没有更改
当我通过搜索结果使用类似的查询时,orderby的工作原理与预期完全相同。我觉得这对树木来说是个小麻烦。
这是我在查询中执行print_r时获得的代码,也许崭新的眼睛可以帮助我找到清晰的解决方案
[query] => Array(
[posts_per_page] => -1
[s] =>
[post_type] => 'teamsi-course-dates'
[meta_query] => Array(
[0] => Array(
[meta_query] => Array(
[relation] => AND
[0] => Array(
[key] => course_date_start_date
[compare] => >=
[value] => 20190212
[type] => DATE
)
[1] => Array(
[key] => course_date_start_date
[compare] => <=
[value] => 20200228
[type] => DATE
)
)
)
[1] => Array(
[0] => Array(
[key] => course_date_start_date
[value] => 20190212
[compare] => >
)
)
[relation] => AND
)
[tax_query] => Array(
[0] => Array(
[taxonomy] => 'teamsi-program-dept'
[field] => name
[terms] => PDMP
)
)
[meta_key] => course_date_start_date,
['orderby'] => meta_value_num,
[order] => ASC
)
我想按日期显示DESC
答案 0 :(得分:0)
我找到了解决方案,在$ args中添加了'suppress_filters'=> true,它允许WP_Query与orderby一起使用,您可以阅读有关的更多信息:https://wordpress.stackexchange.com/questions/82092/wp-query-orderby-breaks-when-using-ajax