@Uffo我想说您的参数是错误的,应该是这样的:
$args = array(
\'post_type\' => \'Event\',
\'posts_per_page\' => 1000,
\'meta_query\'=> array(
array(
\'key\'=>\'event_informations_show_on_the_homepage\',
\'value\'=> \'Show on the homepage\',
\'compare\' => \'==\'
)
),
\'meta_key\'=>\'event_informations_date\',
\'orderby\'=>\'meta_value_num\',
\'order\'=>\'ASC\'
);
按照您的方式,它只是最后一个meta\\u键,将用于过滤查询和排序。我不能百分之百确定这种方法是否有效,但请尝试一下。
希望我能帮上忙。
因此,我认为您需要通过SQL语句过滤组,使其按您想要的方式工作,类似这样的内容:
$args = array(
\'post_type\' => \'Event\',
\'posts_per_page\' => 1000,
\'meta_query\'=> array(
\'relation\' => \'OR\',
array(
\'key\'=>\'event_informations_show_on_the_homepage\',
\'value\'=> \'Show on the homepage\',
\'compare\' => \'==\'
),
array(
\'key\'=>\'event_informations_date\',
)
),
\'orderby\'=>\'meta_value_num\',
\'order\'=>\'ASC\'
);
add_filter(\'posts_orderby\', \'edit_posts_orderby\');
function edit_posts_orderby($orderby_statement) {
$orderby_statement = "mt1.meta_value+0 ASC";
return $orderby_statement;
}