Highlight and Locate Search Terms

Sometimes we have clients that want to give their users a little extra help in finding the search terms they are looking for.

Here is some basic code you can through in your functions.php file to add highlighting to a text string (in my case that is search term).

Obviously, in order for this to work you will need to setup a $_GET variable, probably attached to the link on your search page. That will look something like this:

You will probably want to also setup a background color for your highlight so it is, you know, highlighted:

Lastly, you can also move the user to the first instance of this search term like so: