我一直在尝试根据使用高级自定义字段创建的end\\u date自定义字段订购这些展览。我无法正常工作。我首先需要最近的约会。我也只需要在exhibition_status
属于past
. 对于我的生活,我不能让这个工作,下面的代码只是最新的非工作互动。
$args = array (
\'post_type\' => \'exhibitions\',
\'meta_query\' => array(
\'relation\' => \'OR\',
\'query_one\' => array(
\'key\' => \'exhibition_status\',
\'value\' => \'past\',
),
\'query_two\' => array(
\'key\' => \'end_date\',
\'compare\' => \'>=\',
),
),
\'orderby\' => \'end_date\',
\'order\' => \'ASC\',
\'post_status\' => \'publish\',
\'posts_per_page\' => 10,
\'paged\' => get_query_var( \'paged\' ),
);
日期基于此格式F j,Y
如何获取ACF字段订购的所有帖子end_date
只有在ACF领域exhibition_status
等于past
?
最合适的回答,由SO网友:Sabbir Hasan 整理而成
我已经修改了你现有的代码。你能试试下面的代码吗
$args = array (
\'post_type\' => \'exhibitions\',
\'meta_query\'=> array(
\'relation\' => \'AND\',
array(
\'key\' => \'exhibition_status\',
\'value\' => \'past\',
),
array(
\'key\' => \'end_date\',
\'compare\' => \'EXISTS\',
\'type\' => \'DATE\'
),
),
\'meta_key\' => \'end_date\',
\'orderby\' => \'meta_value\',
\'order\' => \'ASC\',
\'post_status\' => \'publish\',
\'posts_per_page\' => 10,
\'paged\' => get_query_var( \'paged\' ),
);