2013-08-20 226 views
0

我使用wordpress get_comments(),但它出現故障。在每篇文章的底部,我看到了相同的評論。我知道get_comments有一個ID attr,但我應該如何動態分配它?我在single.php中使用註釋並使用comment_template()獲取它們;Wordpress獲得評論問題

在此先感謝

編輯

comment_form($comments_args); 

$post_comments = get_comments(); 
?> 

<?php 
    if ($post_comments) 
    {  
?> 
<section class='post-comments'> 

<?php 


    foreach($post_comments as $comment_each) 
{ 
    $comment_each->comment_content; 
    } 

?> 

</section> 
<?php 
    } 
    else 
    { 
     ?> 
     <div class='no-comment'> 
     <?php 
     _e('No comments to show.'); 
     ?> 
     </div> 
     <?php 
    } 
?> 

雖然是

+0

Get_comments不會發生故障,只需要被正確調用即可。向我們顯示您的代碼,我們可以幫助 – Anigel

+0

有人請幫助我 –

+1

嘗試get_comments(array('post_id'=> $ post-> ID)) – Anigel

回答

1

您需要更換

$post_comments = get_comments(); 

$post_comments = get_comments(array('post_id' => $post->ID))