2014-07-13 52 views
0

無法回顯我想要的數組部分(使用get_comments() WordPress函數)。我一直在閱讀有關,但似乎可以得到它的工作:回聲部分WP get_comments()數組

$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] => [email protected] [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)) 

我在做什麼錯?

+0

由於結果是對象。 – MH2K9

回答

2

嘗試:

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

$comments = get_comments($args); 

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

我知道這是入門級的東西,但是...如果我想回顯[comment_content]值什麼我回聲內循環? – PhilD

+0

'$ comment'是一個對象,所以你可以像這樣迴應評論內容:'echo $ comment-> comment_content;'參見[here](http://codex.wordpress.org/Function_Reference/get_comments#Returns)您可以回顯的對象屬性列表。 – henrywright