如何显示单个post的评论?
how to display comments of single post?
我想在单个 post 页面上显示 post 的评论,但在该页面中我也显示了具有相同类别的其他 post。当我使用 comments_template();其他 post 的评论也显示了。这是我的代码
<?php if(have_posts()): while(have_posts()): the_post(); ?>
// show the single post and get the category of post
<?php endwhile;endif; ?>
if(isset($cats_arr) && !empty($cats_arr)){
$args = array(
'category__in' => $cats_arr,
'posts_per_page'=>3,
'post__not_in' => array( $post->ID ) );
$the_query= new wp_query($args);
if($the_query->have_posts()): while($the_query->have_posts()):
$the_query->the_post(); ?>
//// shoe same category post title and image
<?php endwhile;endif ?>
<?php comments_template(); ?>
你能帮我找到我的问题吗?
非常感谢
添加wp_reset_postdata();到 if 语句
之后的第二个查询结束
我想在单个 post 页面上显示 post 的评论,但在该页面中我也显示了具有相同类别的其他 post。当我使用 comments_template();其他 post 的评论也显示了。这是我的代码
<?php if(have_posts()): while(have_posts()): the_post(); ?>
// show the single post and get the category of post
<?php endwhile;endif; ?>
if(isset($cats_arr) && !empty($cats_arr)){
$args = array(
'category__in' => $cats_arr,
'posts_per_page'=>3,
'post__not_in' => array( $post->ID ) );
$the_query= new wp_query($args);
if($the_query->have_posts()): while($the_query->have_posts()):
$the_query->the_post(); ?>
//// shoe same category post title and image
<?php endwhile;endif ?>
<?php comments_template(); ?>
你能帮我找到我的问题吗? 非常感谢
添加wp_reset_postdata();到 if 语句
之后的第二个查询结束