元查询是嵌套数组。请参见WP_Query section on meta queries.
选项1使用meta_key
和meta_value
直接在查询参数中,而不是作为元查询。
$student_query_args = [
\'post_type\' => \'student_list\',
\'post_status\' => \'publish\',
\'posts_per_page\' => 100,
\'order\' => \'DESC\',
\'meta_key\' => \'program_id\',
\'meta_value\' => 5317,
];
选项2是元查询方法。如果要添加多个阵列,则需要多个阵列。默认关系为
AND
但为了清晰起见,我们将提供:
$student_query_args = [
\'post_type\' => \'student_list\',
\'post_status\' => \'publish\',
\'posts_per_page\' => 100,
\'order\' => \'DESC\',
\'meta_query\' => [
\'relation\' => \'AND\',
[
\'key\' => \'program_id\',
\'value\' => 5317,
],
],
];