comments are coming on improper posts

If someone comments on any post on my site, that comment gets displayed under another post.

Moreover, if I login to my site. And click on logout link (under comment section) it redirects me to another article after log out.

Read More

One possible reason as I read on many places, may be showing related posts. I am using following code for this

<?php do_action('erp-show-related-posts', array('title'=>'Most Related Post', 'num_to_display'=>10, 'no_rp_text'=>'No relevant article found.')); ?>

Which is basically given by a wordpress plugin efficient related post.

Related posts

Leave a Reply

1 comment

  1. It sounds to me like you mucked up the query and the comment form thinks the user’s on the wrong post. Try adding

    wp_reset_query();
    

    to your theme right before your theme adds the comment form.

    If that doesn’t work, do this:

    wp_reset_query();
    global $post, wp_query;
    $post = $wp_query->post;
    setup_postdata($post);