我试图列出一些按自定义字段值(“空格注释”)排序的帖子。它工作得很好,但是,当自定义字段为空时,循环无法获取此帖子。
有没有办法修复它?谢谢:)
$args = array(
\'post_type\' => \'spaces\',
\'post_per_page\' => \'500\',
\'meta_key\' => \'space-comments\',
\'orderby\' => \'meta_value_num\',
\'order\' => \'DESC\',
\'author__in\' => $tradicionalIds,
\'meta_query\' => array(
\'relation\' => \'AND\',
array(
\'key\' => \'space-city\',
\'value\' => $search,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'space-comments\',
\'compare\' => \'EXISTS\',
),
)
);
$query = new WP_query($args);