stdClass Object
(
[meta_id] => 11
[post_id] => 8
[meta_key] => wpp_gpid
[meta_value] => gpid_1124779119
)
stdClass Object
(
[meta_id] => 12
[post_id] => 8
[meta_key] => _edit_last
[meta_value] => 1
)
stdClass Object
(
[meta_id] => 13
[post_id] => 8
[meta_key] => _edit_lock
[meta_value] => 1346228510:1
)
stdClass Object
(
[meta_id] => 16
[post_id] => 8
[meta_key] => _thumbnail_id
[meta_value] => 9
)
这是print_r值
$poster_meta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = '{$poster}'");
如何获得meta_value
和meta_key = thumbnail
meta_key = _edit_last
答案 0 :(得分:5)
将其视为一个对象。检查how objects工作。
foreach($poster_meta as $object){
echo $object->meta_id."\n";
echo $object->post_id."\n";
echo $object->meta_key."\n";
echo $object->meta_value."\n";
}
答案 1 :(得分:2)
如果你想在wordpress中获取元键值,那么
试试这段代码: -
$team_counter = get_post_meta($post->ID, 'team_counter', true);
get_post_meta是wordpress库默认函数