Support » Fixing WordPress » Funny comments error, mismatching with the right article

  • Hi!
    I get a weird, funny effect with the comments at the bottom of my articles. Time to time no comments appear, even if they’re supposed to, or instead, comments of an other articles take place.

    Basically I’ve to refresh, and the second time I do, finally I get the right comments matching the right article.

    Obviously this causes trouble to visitors.

    My website:

    Any idea, please?

    Thanks in advance, ciao!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Michael


    Forum Moderator

    it is possible, that the code for the ‘Articles on similar topics’ section does not restore the query_string properly;

    try to add wp_reset_query(); after this code, or before the comment section.

    It makes sense and it’s probably the problem. I added wp_reset_query(); but with no luck.

    This the part of the code that fetches the query.

    $rand_posts = get_posts( $query_args );

    Is it the wrong way to operate a query beside the main loop?

    Also, I keep the comments outside the loop, after endwhile;

    If I skip the whole code for listing similar post, the comments are just fine.

    Thanks for your help, ciao!

    Well, I omitted the arguments I pass to the query, but I guess it’s not the critical point. Anyway the whole function to fetch similar posts is published here:
    …and sure thing I would like it to work with no trouble for who eventually decides to implement it.



    Forum Moderator

    try and save the $post object into a $temp variable before your get_posts code, and restore it at the end:

    change line12 of your function code in your srticle to:
    global $post; $temp = $post;

    change line85 of your function to:

    $post = $temp; }

    Hi again!
    I tried with the suggestion,

    $post = $temp and then $temp = $post, with no success. I tried adding wp_reset_query(); and wp_reset_postdata();.

    Nothing… the comments still got messy. All the above were superfluous, since the problem was here:

    foreach( $posts_lot as $post ) { ...

    So now is something like:
    foreach( $posts_lot as $post2 ) { ...
    …I still have to decide how to call it.

    And it works fine. For now 😀

    Thanks for the support, anyway! Ciao!

    We are getting a similar experience with our blogs. I’m getting all kinds of weird comments about our commercial blog as if we were replying to the blogs of others, but we are certainly not doing that. We are simply posting blogs.

    Is this an issue sitewide?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Funny comments error, mismatching with the right article’ is closed to new replies.