WordPress.org

Plugin Directory

Highlight Search Terms

Very lightweight jQuery script that wraps search terms in an HTML5 mark tag within wp search results or when referrer is a non-secure search engine.

To make it work, you will need to take up to three steps, depending on your wishes and WordPress theme. (I) A normal installation and activation procedure; (II) adding CSS styling rules to get highlighting for older browsers that do not support HTML5 like Internet Explorer 8 and below; and (III) Make sure your theme uses any of the recognized classes or ID's for the post content div so that the script knows where and where not to look for search terms.

I. Install now or use the slick search and install feature (Plugins > Add New and search for "highlight search terms") in your WP2.7+ admin section or follow these basic steps.

  1. Download archive and unpack.
  2. Upload (and overwrite) the /highlight-search-terms/ folder and its content to the /plugins/ folder.
  3. Activate plugin on the Plug-ins page

II. Optionally add at least one new rule to your themes stylesheet (style.css or a custom stylesheet or a custom css plugin) to style highlightable text.

For example use .hilite { background:#D3E18A; } to get a moss green background on search terms found in the content section (not header, sidebar or footer; assuming your Theme uses a div with class "hentry").

Please find more examples under the Other Notes tab.

III. 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 class is recognized by the hilite script, which means search terms found in post and page content will be highlighted but not similar terms that coïncidentaly reside 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 (which might include the header, sidebar and footer areas) but if none of those are found, it will not work for you out of the box. See the last of the FAQ's for ways to make it work.

Requires: 2.7 or higher
Compatible up to: 4.6
Last Updated: 7 days ago
Active Installs: 8,000+

Ratings

5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

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,1,1
100,3,3 100,1,1 100,2,2
67,3,2
100,2,2 100,1,1
100,1,1 100,1,1
100,1,1 100,2,2
100,1,1
100,3,3
100,1,1 100,2,2
0,1,0 100,1,1
100,2,2
100,1,1
100,1,1
100,1,1 100,1,1
0,1,0
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1 100,1,1
100,1,1
100,1,1 100,1,1
100,1,1