WordPress.org

Ready to get started?Download WordPress

Forums

Comments get assigned to the wrong post. (12 posts)

  1. montana949
    Member
    Posted 4 years ago #

    Whenever anyone including admin leaves a comment it gets assigned to a different post. It happens on all the posts on my site. The weird thing is it will still show up on the correct post page but when you leave a comment it goes to the old post with no comments. If you go back to the page you will see it. In the wp-admin dashboard you see the comment assigned to the wrong post in comments tab.

    I tried using another theme and it didnt fix anything. I also installed some database repair plugins and they did not fix the problem. I think it may be my functions.php file is messed up?

    I really would love help fixing this, I have my blog where I am happy and it is a business blog so I really need it working correctly! Thanks so much for the time and support you put into the wordpress community!

  2. minnemom
    Member
    Posted 4 years ago #

    This has been happening to me the past few days as well. I haven't changed anything that I'm aware of.

    Hope someone can help us fix this!

  3. katrinaneufeld
    Member
    Posted 4 years ago #

    This is happening on my site, too. I'm running WP Version 2.7.1 and Arthemia Premium 1.0.

  4. katrinaneufeld
    Member
    Posted 4 years ago #

    I think I fixed my problem.

    I had added some extra code to single.php that should have gone in the loop. Removing this code seemed to have solved the problem. The actual code removed may or may not be relative. It's meant to create a list of related posts based on tags at the end of the article. I've included it below for the sake of curiosity.

    <?php
    //for use in the loop, list 5 post titles related to first tag on current post
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
      echo '<strong>Related Posts:</strong><ul>';
      $first_tag = $tags[0]->term_id;
      $args=array(
        'tag__in' => array($first_tag),
        'post__not_in' => array($post->ID),
        'showposts'=>5,
        'caller_get_posts'=>1
       );
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
          <?php
        endwhile;
      }
      echo '</ul>';
    }
    ?>
  5. Cocktaille
    Member
    Posted 4 years ago #

    Same here. Also deleted the code above in my page. And everything works fine now. When the code displayed related articles on the page, the comments given on the original article were mapped with the article in the related post.

    Strange thing, 'cause I didn't change the code for showing related articles.

  6. 7sins
    Member
    Posted 4 years ago #

    @katrinaneufeld : Use this code piece ..this should work fine..

    <?php
    //for use in the loop, list 5 post titles related to first tag on current post
    $backup = $post;  // backup the current object
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
      echo '<strong>Related Posts:</strong><ul>';
      $first_tag = $tags[0]->term_id;
      $args=array(
        'tag__in' => array($first_tag),
        'post__not_in' => array($post->ID),
        'showposts'=>5,
        'caller_get_posts'=>1
       );
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
          <?php
        endwhile;
      }
      echo '</ul>';
      $post = $backup;  // copy it back
      wp_reset_query(); // to use the original query again
    }
    ?>

    The 1st line and the last two lines that are added are the solution to the missing puzzle.

  7. WayneSmallman
    Member
    Posted 4 years ago #

    That code wreaks total havoc on my installation of WordPress 2.8.

    All comments, previous articles, tags and categories (basically everything) is completely wrong on every article page.

  8. buddha trance
    Member
    Posted 4 years ago #

    The code below for related posts works fine on my blog, since 2.7 up to the current 2.8.1 - you may want to give it a try. I switched to it, after having the same problems with comments being assigned to a different post.

    <?php
    	$original_post = $post;
    	$tags = wp_get_post_tags($post->ID);
    	$tagIDs = array();
    	if ($tags) {
    		$tagcount = count($tags);
    		for ($i = 0; $i < $tagcount; $i++) {
    			$tagIDs[$i] = $tags[$i]->term_id;
    		}
    	$args=array(
    	'tag__in' => $tagIDs,
    	'post__not_in' => array($post->ID),
    	'showposts'=>5,
    	'caller_get_posts'=>1
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    	echo '<strong>Similar Posts</strong>';
    	while ($my_query->have_posts()) : $my_query->the_post(); ?>
    		<ul>
    			<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    		</ul>
    	<?php endwhile;
    	}
    	}
    	$post = $original_post;
    	wp_reset_query();
    	?>
  9. Ashfame
    Member
    Posted 4 years ago #

    Its happening with me too. I am using YARPP Related Posts Plugin, not custom code for showing related posts. What should I do? Moreover how can the comments be fixed to show up on the correct post? Is it just by changing the POST ID in the comments table or some more work is required?

  10. Vichingo
    Member
    Posted 4 years ago #

    What happens to me seems to be different: Everyday in one or two posts appear comments dated about one year before. Only solution for me so far has been opening post by post and looking for comments not related to it and with an older date.

    Any solution for that?

  11. Vichingo
    Member
    Posted 4 years ago #

    What happens to me seems to be different: Everyday in one or two posts appear comments dated about one year before. Only solution for me so far has been opening post by post and looking for comments not related to it and with an older date.

    Any solution for that?

  12. alexstudio
    Member
    Posted 4 years ago #

    Thanks a lot 7sins this fixed my problem as well.

Topic Closed

This topic has been closed to new replies.

About this Topic