Family Encyclopedia >> Electronics

How to highlight search terms in results in WordPress

In an attempt to make your WordPress search even more user-friendly, you can highlight search terms in the results. We did this for one of our clients, so we thought it would be useful for other users. In this article, we will show you how you can highlight search terms in results in WordPress.

How to highlight search terms in results in WordPress

First open your search.php and look for the following code:

 

Replace the above code with:

 

Make sure to paste this line above the title code:

 \ 0', $ título); ?> 

Now open your CSS file and add the style for the class search excerpt, and the term will be highlighted. Currently the code is making the search terms bold. You can try this simple CSS in your theme's style sheet.

 strong.search-excerpt background-color: yellow; color azul; 

Source:Michael Martin