如何在wordpress中显示特定帖子的评论?

时间:2015-06-01 05:09:58

标签: wordpress

我正在尝试在wordpress中显示所选帖子的评论。如何通过ID显示特定帖子的评论?

1 个答案:

答案 0 :(得分:0)

首先找出你要从中获取评论的帖子的post_id。

<?php 
  // Get all comments of post_id 5
  $args = array('post_id' => 5);
  $comments = get_comments( $args ); 

  // Loop through your comments
  foreach($comments as $comment) :
    echo($comment->comment_author . '<br />' . $comment->comment_content);
  endforeach;
?>