我搜索了一会儿,但没有找到任何解决方案。我使用了这些函数listed here.它输出如下内容:
Array
(
[0] => 15
[1] => 30
[2] => 50
)
但我想要这样的东西:Array
(
[post_id_1] => 15
[post_id_2] => 30
[post_id_3] => 50
)
这是函数中使用的$wp查询:function get_meta_values( $key = \'\', $type = \'post\', $status = \'publish\' ) {
global $wpdb;
if( empty( $key ) )
return;
$r = $wpdb->get_col( $wpdb->prepare( "
SELECT pm.meta_value FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = \'%s\'
AND p.post_status = \'%s\'
AND p.post_type = \'%s\'
", $key, $status, $type ) );
return $r;
}