Duplicate Search Results (4 posts)

  1. Drew
    Posted 9 years ago #

    Hello All,

    I seem to have another WordPress issue. Pretty much all the posts that I have are in multiple categories. When I do a search on my site (via wordpress' search funcitons), say for instance I search for "css" (no quotes), it returns multiple results.

    I have searched the forums, but no solutions have solved my issue. I could just start disabling plugins, but I don't know if there might be a simple fix to this that I'm just overlooking.

    The site is my personal site, http://www.deckerd.com

    Any help is appriciated.

  2. Drew
    Posted 9 years ago #

    *bump* - maybe, since I posted this around 4AM, nobody has seen this.

    Does anyone possibly know the answer to this?


  3. ttech5593
    Posted 9 years ago #

    Help is on the way. Hopefully. :)

  4. jvolvovski
    Posted 8 years ago #

    i think i figured this one out.
    since the duplicates always appear next to one another you just have to have 2 variables that remember the id of the current post, and the id of the previous post. if the ids are the same you don't show anything.

    <? $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; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic