Reputation: 177
I want to show comments of a post on single post page, but in that page I show the other post with same category too. when I use comments_template(); the comments of other post shown too. here is my code
<?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(); ?>
Can you help me find my problem? Thanks a lot
Upvotes: 0
Views: 136
Reputation: 829
add wp_reset_postdata(); to end of second query after if statment
Upvotes: 1