• mingya

    (@mingya)


    I’ve not modified the theme or touch the code, just out of the blue, comments were mismatched from its original post ID.

    For example, original post ID 10 and 14.
    Then comments from post ID 10 shows up under Post ID 14, and vice versa.
    Checked db, under comment table, the post ID is ok, yet it’s not retrieved correctly under the supposed post with the same ID.

    Anyone here knows what’s going on with this problem?

Viewing 7 replies - 1 through 7 (of 7 total)
  • esmi

    (@esmi)

    Site url?

    Thread Starter mingya

    (@mingya)

    Site is intranet. Any other way besides a public site?

    esmi

    (@esmi)

    Unless you can provide a link to a publically accessible site, no one will be able to offer much in the way of specific help. Have you tried running a database repair?

    Thread Starter mingya

    (@mingya)

    I did a database repair, originally found a duplicate on the comment index, then I export the db, port it to a new set of wordpress setup. There I notice the post_ID is matching the comment_post_ID, but wp_list_comments retrieve the comments with a different post_ID.

    Unfortunately I cannot produce a public site immediately, however, if you may help explain how wp_list_comments retrieve it’s data, isn’t based on the comment_post_ID key on the single.php of a default theme?

    Thread Starter mingya

    (@mingya)

    Found the culprit to this inconsistency. It’s the loop within loop inside single.php that caused this problem, but still don’t know what went wrong. Please help.

    The loops were written as follow:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div <?php post_class(); ?> id=”post-<?php the_ID(); ?>”>
    <h2>” rel=”bookmark” title=”<?php printf(__(‘Permanent Link to %s’), the_title_attribute(‘echo=0’)); ?>”><?php the_title(); ?></h2>
    <div class=”entry”>
    <?php the_content(__(‘Read the rest of this entry »’)); ?>
    <?php wp_link_pages(array(‘before’ => ‘<p>‘ . __(‘Pages:’) . ‘ ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>
    <?php the_tags( ‘<p class=”tags”>’ . __(‘Tags:’) . ‘ ‘, ‘, ‘, ‘</p>’); ?>
    </div>
    <?php
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
    echo ‘Related Posts’;
    $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(); ?>
    <p>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></p>
    <?php
    endwhile;
    }
    }
    ?>
    <?php comments_template(”, true); ?>
    <?php endwhile; else: ?>
    <h2 class=”center”><?php _e(‘Sorry, no posts matched your criteria.’, ‘ctn1’); ?></h2>
    <?php include (TEMPLATEPATH . “/searchform.php”); ?>>
    <?php endif; ?>
    </div>

    Thread Starter mingya

    (@mingya)

    sorry, forgot to wrap the code with “code” shortcode, moderator, please help revise that post, so it’s easier to read. Thank you.

    Thread Starter mingya

    (@mingya)

    FYI, the loop within the loop was taken from MichaelH post in the following link:
    http://wordpress.org/support/topic/247918?replies=14

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Problem of comments not matching post ID’ is closed to new replies.