Я пытаюсь вписать WordPress в свой веб-сайт, и вместо создания темы я просто использую API для размещения блогов на моем веб-сайте.Я застрял с получением комментариев.Когда я вызываю $ comments = get_comments (array ('post_id =>'. $ Post-> ID, 'order' => 'ASC'));Я получаю комментарии для всех сообщений.Я не разработчик PHP, я только учусь сейчас.Я на самом деле Java-разработчик .. В любом случае вот код, который не работает:
<?php global $more;
$more = -1;
$posts = get_posts('numberposts=10&order=ASC');
$counter=0;
foreach ($posts as $post) {
setup_postdata($post);?>
<div class="article">
<h2><?php the_title(); ?></h2>
<div class="clr"></div>
<h3><?php the_time('F j, Y'); ?></h3>
<div id="content<?php echo $counter; ?>" class="section sectionborder">
<?php the_content(); ?>
<h2>Post ID:<?php echo $post->ID?></h2>
/**
* This is where I call get_comments and the post is being passed
* correctly to it. Since the post ID is printed correctly above. But
* I am getting comments not related to this post as well
*/
<?php
$comments = get_comments(array('post_id=>'.$post->ID,'order' => 'ASC'));
echo '<h3>Comments</h3>';
foreach($comments as $comment) :
echo('<div class="comment">'
.$comment->comment_content.
'<span class="comment-author">-'. $comment->comment_author. '</span>
<span class="comment-date">'.date('Y-m-d H:i', strtotime($comment->comment_date)) .'</span>
</div>');
endforeach;
?>
</div>
<div id="a<?php echo $counter; ?>">
<a href="#">Read More</a>
</div>
</div>
<br/>
<hr/>
<?php $counter++; ?>
<?php } ?>