回复WP get_comments()数组的一部分

时间:2014-07-13 10:46:56

标签: php arrays wordpress

无法回显我想要的数组部分(使用get_comments() WordPress功能)。我一直在阅读它,但似乎可以让它发挥作用:

$args = array(
'meta_value'   => 'tagline111'
);

echo get_comments($args[comment_content][0]);

但我得到:"Array"

我已尝试过各种方式:将[]放在括号内,然后在引号周围放置,使用双括号......

当我print_r(get_comments($args));时:

Array ( [0] => stdClass Object ( [comment_ID] => 8 [comment_post_ID] => 367
[comment_author] => pppaul [comment_author_email] => af@gmail.com [comment_author_url]
=> [comment_author_IP] => 127.0.0.1 [comment_date] => 2014-07-13 06:41:11 
[comment_date_gmt] => 2014-07-13 06:41:11 [comment_content] => some content 
[comment_karma] => 0 [comment_approved] => 1 [comment_agent] => Mozilla/5.0 (Windows
NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0 [comment_type] => [comment_parent] 
=> 0 [user_id] => 1 [meta_id] => 28 [comment_id] => 8 [meta_key] => referance2  
[meta_value] => tagline111 ) ) 

我做错了什么?

1 个答案:

答案 0 :(得分:2)

尝试:

$args = array(
    'meta_value' => 'tagline111'
);

$comments = get_comments( $args );

foreach( $comments as $comment ) :
    // echo something
endforeach;