Support » Fixing WordPress » Duplicate Search Results

  • Drew


    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,

    Any help is appriciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Drew


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

    Does anyone possibly know the answer to this?


    Help is on the way. Hopefully. 🙂

    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; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Duplicate Search Results’ is closed to new replies.