How can I get the search terms highlighted without plugin?
Add these 2 functions to your functions.php
To use the_content for your search results use the function below:
In your loop or search.php file call
In your css add the search-highlight class which will highlight all searched words in yellow.
The above works well I've run the similar code, but tie the title and excerpt together. But found it breaks when someone enters a space " " either at the beginning or end of a search query term.
So Ive add this line:
Hope this proves to help others.
The above solutions break the page if the search term appears inside HTML tags. You should use something like:
protected by toscho♦ Oct 29 '12 at 11:22
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?