Reputation: 9173
I'm using wordpress get_comments()
, but it malfunctions. At the bottom of each post I see the same comments. I know get_comments has an ID attr, but How should I assign it dynamically? I'm using comments in single.php and getting them with comment_template()
;
thanks in advance
EDIT
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
}
?>
While be
Upvotes: 0
Views: 48
Reputation: 3437
You need to replace
$post_comments = get_comments();
with
$post_comments = get_comments( array( 'post_id' => $post->ID))
Upvotes: 1