Post with wrong comment
-
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… 🙁
Site url?
This >>> http://lariduarte.com/
Thank youmake sure that those ‘related posts’ codes are closed with
wp_reset_postdata()
orwp_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"> <!--//////////////////////////////CONTEUDO//////////////////////////////--> <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> <div class="content-post"><?php the_content(); ?></div> </div><!--end box-post--> <?php $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; $args=array( 'category__in' => $category_ids, 'post__not_in' => array($post->ID), 'showposts'=>3, 'caller_get_posts'=>1 ); $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()) { $my_query->the_post(); ?> <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> </div> <?php } 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]
instead:
<?php endwhile;wp_reset_query(); ?>
try:
<?php endwhile; wp_reset_postdata(); ?>
alternatively, after this line:
</div><!--end box-post-->
add:
<?php $temp = $post; ?>
and before this line:
<?php comments_template(); ?>
add:
<?php $post = $temp; ?>
Hello! Thank you very much alchymyth and esmi :)… Problem solved!
- The topic ‘Post with wrong comment’ is closed to new replies.
(@aline_rodrigues)
11 years, 3 months ago
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?