Wordpress获取评论问题


Wordpress getting comments issue

我正在使用wordpress get_comments(),但它出现了故障。在每个帖子的底部,我都看到了相同的评论。我知道get_comments有一个ID属性,但我应该如何动态分配它?我在single.php中使用注释,并使用comment_template()获取它们;

提前感谢

编辑

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
    }
?>

当是时

您需要更换

$post_comments = get_comments();

带有

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