Support » Plugins and Hacks » [Resolved] Inconsistent Search Result Highlighting

[Resolved] Inconsistent Search Result Highlighting

  • Using search result highlighting, I am getting inconsistent results.

    Some posts return a modified excerpt, without any highlighting. Some posts return simply ellipses.

    Example, a search for ‘downtown’ returns this excerpt,

    by PCJ Editor Wayne Senville, reporting from Niles, Michigan Part of Main Street in Niles, Michigan (click on photo to view at larger size). Lisa Croteau It was raining hard when…

    For this article, http://plannersweb.com/2009/06/a-main-street-succeeds-in-tough-times/ which has the word ‘downtown’ in it’s content 36 times.

    Then some articles have an excerpt of nothing more than

    Example, this article – http://plannersweb.com/2005/04/sizing-up-downtown/ with the word ‘downtown’ in it’s content 17 times.

    And important to note, on the same results page, this article: http://plannersweb.com/2012/10/human-squirrels/

    Shows a properly highlighted excerpt:

    Fort Andross in Brunswick, Maine. All photos in this post by Wayne Senville unless otherwise noted. Brunswick, Maine (population just over 20,000) has a wonderful downtown — stretching about ten blocks between…

    Any ideas?

    Thanks Mikko!

    PS – I’ve turned the highlighting off on the live site until I can resolve this.


Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Mikko Saari


    There’s a bug in the current version. If you want a quick fix, check lib/excerpts-highligths.php, find the two occurrances of usort() and change both to uasort(), with the same parameters. That should fix at least part of this.

    Do that, and tell me how much that fixes and we can continue from there.

    Worked for me. Many thanks!



    Ahh thank you! This fixed my issue as well. Relevanssi was not creating custom excerpts & snippets around the search terms. It created the right length of excerpt, identified the matches, and highlighted them, if they were in the visible part of the excerpt, but did not create custom excerpts using the search terms until I implemented your quick fix. I have my template set like this:

    <?php /* Start the Loop */ ?>
       <?php while ( have_posts() ) : the_post(); ?>
       <h3><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a>
       <?php if (function_exists('relevanssi_the_excerpt')) { relevanssi_the_excerpt(); }; ?>
        <a href="<?php echo get_permalink(); ?>"> View the full page.</a>
        <?php endwhile; ?>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Great plugin by the way. Thanks for the help.

    this doesn’t fix it for me. v. 3.1.6

    Plugin Author Mikko Saari


    Ps3hero, based on the other thread, your problem is different and the solution is here.

    @mikko: take a look at this: http://www.commwork.de/kunden/wigy/gremien/kollegium/

    and now search (top right) for the word “Schumacher” (this is a name). now you have this:


    with 4 results. the top result doesn’t show the word because it’s in a custom field and at the nearly bottom of the page. is it possible to show the word “Schumacher” in the search result excerpt?

    Plugin Author Mikko Saari


    Yes, and the answer is still in the other thread.

    got it working now, thank you very much!!!!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] Inconsistent Search Result Highlighting’ is closed to new replies.