我有两个高级自定义字段,脚注和编辑日期(日期选择器字段)。我想要实现的是wp_query 其中脚注不为空。我希望根据编辑的日期对输出进行排序。
我尝试了多种解决方案,但都无法解决这个问题。
这是我最好的尝试:
$args = array(
\'post_type\' => \'page\',
\'meta_query\' => array(
\'relation\' => \'AND\',
array(
\'key\' => \'footnote\',
\'value\' => array(\'\'),
\'compare\' => \'NOT LIKE\'
),
array(
\'key\' => \'date_edited\',
\'value\' => array(\'\'),
\'type\' => \'DATE\',
\'compare\' => \'=\'
\'orderby\' => \'meta_value_num\',
\'order\' => \'DESC\'
)
),
\'post_status\' => \'publish\',
\'posts_per_page\' => 10,
\'no_found_rows\' => true
);
显然,这是行不通的-而且是date\\u编辑的数组不正确。是否有人看到我的错误,并有正确的解决方案来显示?
EDIT after @majick responded
这是可行的。是对@majick建议的一个小小修改:
$args = array(
\'post_type\' => \'page\',
\'meta_query\' => array(
array(
\'key\' => \'footnote\',
\'compare\' => \'EXISTS\',
),
),
\'post_status\' => \'publish\',
\'posts_per_page\' => 10,
\'no_found_rows\' => true,
\'orderby\' => \'meta_value_num\',
\'meta_key\' => \'date_edited\',
\'order\' => \'DESC\'
);