WP returns duplicates results on search
-
Hi,
My search is returning duplicates results.
I’ve tried to use filter by id like :<? $oldID = 0; ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <? $currentID = $post->ID; ?> <? if ($oldID == $currentID) { ?> // shows nothing if the ids are the same <? } else { ?> // search result goes here <? $oldID = $currentID; ?> <? } ?> <?php endwhile; ?> <?php else : ?> No posts matched your search results. <?php endif; ?>
but doesn’t work… enter in a infinity loop
my code:<?php if ( have_posts() ) : ?> <div id="content-pages"> <?php while ( have_posts() ):?> <div class="postagem-search"> <div class="titulo-post"> <a href="<?php the_Permalink();?>"> <?php the_title();?></a> <?php the_post();?><a href="<?php the_Permalink();?>"><button type="button" class="btn btn-primary btn-sm pull-right">Continuar Lendo...</button></a> </div> <?php if(has_post_thumbnail()):?> <div class="post-thumb"> <?php the_post_thumbnail();?> </div> <?php endif; // fim do if has_post_thumbnail?> <?php if (has_excerpt() ) : ?> <div class="resumo-post"> <?php the_excerpt(); ?> </div> <?php endif; // fim do has_excerpt?> </div> <!--fim da div postagem-search--> <?php endwhile;?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘WP returns duplicates results on search’ is closed to new replies.