Plugin Directory

Highlight Search Terms

Lightweight search terms highlighter using jQuery. Wraps search terms with class="hilite" when referer is a search engine or within wp searc

Download Version 0.6

Highlights search terms using jQuery when referer is a Google, Yahoo, Lycos, Bing, Ask, Baidu and Youdao search engine or within WordPress generated search results. This plugin is a light weight, low resource demanding and very simple fusion between How to Highlight Search Terms with jQuery - theme hack by Thaya Kareeson and Search Hilite by Ryan Boren.

NOTE: You will NOT see any highlighting until you defined a CSS hilite styling! Read on below So what do I need to do? and Installation for more detailed instructions. You can find CSS examples in Other Notes.

What does it do?

This low impact plugin uses only two action hooks, wp_header where it needs to define some variables and wp_footer to insert the jQuery library (included in your WordPress package; only if not already loaded) and to add the hilite jQuery extension to your page source code. The jQuery extension that runs after the page has loaded, finds all search terms on that page inside each div with class hentry (or ID content, main or wrapper) and wraps them in <span class="hilite term-N"> ... </span> tags. Note that N is a number starting with 0 for the first term used in the search phrase increasing 1 for each additional term used. A (part of a) search phrase wrapped in quotes is considered as a single term.

What does it NOT do?

There are no CSS style rules set for highlighting. You are free to use any styling you wish but you absolutely need to define at least one rule to make the highlights visible.

So what do I need to do?

1. Define CSS rules There are no configuration options and there is no predefined highlight styling. You are completely free to define any CSS styling rules in your themes main stylesheet (style.css) or use any Custom CSS plugin like Custom CSS to get a result that fits your theme best. You can find basic instructions and CSS examples under the Other Notes tab.

2. Check your theme In most up to date themes (including WP's own Default theme) post and page content is shown inside a div with class hentry. This means search terms found in post and page content will be highlighted but not similar terms that accidentaly show in the page header, sidebar or footer. If your current theme does not use the hentry class (yet), this plugin will look for IDs content, main and finally wrapper but if none of those are found, it not work for you out of the box. See the last of the FAQ's for ways to make it work.

Author: RavanH

Requires: 2.3 or higher
Compatible up to: 3.1.4
Last Updated: 2011-1-3 Downloads: 9,613

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(21 ratings)

Compatibility

+
=
Not enough data

2 people say it works.
0 people say it's broken.

Log in to vote.

100,1,1
50,4,2
50,4,2 100,3,3
0,1,0
100,1,1 67,6,4
50,2,1
100,1,1
0,1,0
100,2,2
100,1,1
100,3,3
100,2,2