1
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_valueofmeta_key = thumbnailmeta_key = _edit_last

4

2 回答 2

5

把它当作一个对象。检查对象如何工作。

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";
}
于 2012-08-29T13:37:20.557 回答
2

如果你想在 wordpress 中获取元键值,那么

试试这个代码: -

$team_counter = get_post_meta($post->ID, 'team_counter', true);

get_post_meta 是 wordpress 库默认函数

于 2012-08-29T13:41:15.600 回答