Support » How-To and Troubleshooting » [Resolved] Post with wrong comment

[Resolved] Post with wrong comment

  • Hi everyone,
    I have problem about comments, My post appear with wrong comments. I have related posts in my single.php.
    Can someone help me?

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


    Forum Moderator

    Have you tried:

    – deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    – switching to the default theme to rule out any theme-specific problems.

    resetting the plugins folder by FTP or PhpMyAdmin. Sometimes, an apparently inactive plugin can still cause problems.

    Hello, I already tried that, but nothing… 🙁



    Forum Moderator

    Site url?

    This >>> http://lariduarte.com/
    Thank you

    Moderator Michael


    Forum Moderator

    make sure that those ‘related posts’ codes are closed with wp_reset_postdata() or wp_reset_query()

    Hello, I do. This is my code. but not work.

    <?php get_header(); ?>
    <div class="content">
        <div class="corpo">
            <div class="pd-all-default">
            <div class="f-left box-left">
                <?php while ( have_posts() ) : the_post(); ?>
                <div class="box-post">
                    <div class="data sprite">
                        <div class="pd-data">
                            <div class="date-month"><?php the_time('d'); ?>/<?php the_time('M'); ?></div>
                            <div class="date-year"><?php the_time('Y'); ?></div>
                        </div><!--end pd data-->
                    </div><!--end data-->
                    <div class="titulo-post sprite">
                        <a>" class="titulo-post-link"><?php echo substr(the_title('', '', FALSE), 0, 50); ?></a>
                        <div class="tags"><?php the_tags('', ', ', ''); ?></div>
                    <div class="content-post"><?php the_content(); ?></div>
                </div><!--end box-post-->
                    $randomPost = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY rand() LIMIT 1");
                    $categories = get_the_category($post->ID);
                    if ($categories) {
                    $category_ids = array();
                    foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
                    'category__in' => $category_ids,
                    'post__not_in' => array($post->ID),
                    $my_query = new wp_query($args);
                    if( $my_query->have_posts() ) {
                    echo '<div id="postsRelacionados"><h2 class="titulo-posts-relacionados"> Posts Relacionados</h2>';
                    while ($my_query->have_posts()) {
                    <div class="conteudoRelacionados">
                    <div class="fotoRelacionados"><a>" title="<?php the_title(); ?>" class="link-img-posts-relacionados"><?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'pequena' ); } ?></a></div>
                    <div class="tituloRelacionados"><a>" title="<?php the_title_attribute(); ?>" class="link-img-posts-relacionados"><?php the_title(); ?></a></div>
                    echo '</div>';
               <?php endwhile;wp_reset_query(); ?>
               <?php comments_template(); ?>
            </div><!--end f left-->
            <?php get_sidebar(); ?>
        </div><!--end pd-all-default-->
    </div><!--end corpo-->
    </div><!--end content-->
    <?php get_footer(); ?>

    [please mark any posted code – http://codex.wordpress.org/Forum_Welcome#Posting_Code – the above code is partly broken by the forum parser]

    Moderator Michael


    Forum Moderator


    <?php endwhile;wp_reset_query(); ?>


    <?php endwhile; wp_reset_postdata(); ?>

    alternatively, after this line:

    </div><!--end box-post-->


    <?php $temp = $post; ?>

    and before this line:

    <?php comments_template(); ?>


    <?php $post = $temp; ?>

    Hello! Thank you very much alchymyth and esmi :)… Problem solved!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] Post with wrong comment’ is closed to new replies.