Plugin Directory

Highlight Search Terms

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

Other Notes

Many blogs are already top-heavy with all kinds of resource hungry plugins that require a lot of options to be set and subsequently more database queries. The Highlight Search Terms plugin for WordPress is constructed to be as low impact / low resource demanding as possible, keeping server response and page load times low. This is done by going without any back-end options page, no filtering of post content and no extra database entries. Just two action hooks are used: wp_footer and wp_head. The rest is done by jQuery javascript extention and your own CSS.

To get you started with your own CSS styling that fits your theme, see the following examples.

CSS Instructions

Go in your WP admin section to Themes > Edit and find your Stylesheet. Scroll all the way to the bottom and add one of the examples (or your modification of it) on a fresh new line.

Basic CSS Examples

.hilite { background-color:#D3E18A }

For a moss green background highlighting.

.hilite { background-color:yellow }

Yellow background highlighting.

.hilite { background-color:#9CD4FF; font-weight:bold }

A light blue background with bold font.

.hilite { background-color:#FFCA61; color:#000000 }

Orange background with black font.

For more intricate styling, see the advanced example below.

Advanced CSS Example

If you want to give different terms used in a search phrase a different styling, use the class "term-N" where N is a number starting with 0, increasing 1 with each additional search term, to define your CSS rules. The below example will make every instance of any term used in the query show up in bold text and a yellow background except for any instance of a second, third and fourth term which will have respectively a light green, light blue and orange background.

.hilite { background-color:yellow; font-weight:bold } /* default */
.term-1 { background-color:#D3E18A } /* second search term only */
.term-2 { background-color:#9CD4FF } /* third search term only */
.term-3 { background-color:#FFCA61 } /* fourth search term only */

Keep in mind that for the first search term the additional class "term-0" is used, not "term-1"!

Known issues

  1. If your theme does not wrap the main content section of your pages in a div with class "hentry", this plugin will not work for you out of the box. However, you can make it work. See the last of the FAQ's for an explanation.

  2. Josh pointed out a conflict with the ShareThis button. I have no clue why this happens but since version 0.5 jQuery is used in so called NoConflict mode. Please let me know if the problem still exists. Thanks!

  3. When search engine referrer is using SSL (notice the https:// in the URL, usually when logged in as Google user) and your WordPress site is not, then the search terms cannot be determined. There is no way to get around that issue.

Thank you, Jason for pointing out a bug for IE7+, fixed in 0.2.

Please provide me with a bugreport, suggestion or question if you run into any problems!

Requires: 2.3 or higher
Compatible up to: 4.4.2
Last Updated: 4 months ago
Active Installs: 7,000+


5 out of 5 stars


1 of 1 support threads in the last two months have been marked resolved.

Got something to say? Need help?


Not enough data

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

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