我也在努力解决这个问题(只是我在按基于文本的元值排序)。以下是解决问题的方法:
$meta_query = array(
\'relation\' => \'OR\',
array(
\'key\' => \'property_reference\',
\'value\' => false,
\'type\' => \'BOOLEAN\',
),
array(
\'key\' => \'property_reference\',
\'compare\' => \'NOT EXISTS\',
\'value\' => \'\', //have to set value due to bug: core.trac.wordpress.org/ticket/23268
),
array(
\'key\' => \'property_reference\',
)
);
$query->set( \'meta_query\', $meta_query );
$query->set( \'meta_key\', \'property_reference\' );
$query->set( \'orderby\', \'meta_value\' );
。。。哪里
property_reference
是我的自定义字段。