How to Highlight the Search Terms in Results in WordPress

In an strive to make your WordPress seek much more consumer pleasant, you’ll spotlight the seek phrases in the effects. We did this for certainly one of our shoppers, so we concept it could be helpful for different customers. In this text we will be able to display you ways you’ll spotlight seek phrases in the effects in WordPress.

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

<?php the_title(); ?>

Replace the above code with:

<?php echo $identify; ?>

Make positive that you simply paste this line above the identify code:

<?php $identify = get_the_title(); $keys= explode(" ",$s); $identify = preg_replace('/('.implode('|', $keys) .')/iu', '<sturdy elegance="search-excerpt"></sturdy>', $identify); ?>

Now open your CSS record and upload the styling for the elegance search-excerpt, and it’s going to spotlight the time period. Currently the code is making the seek phrases daring. You can do this easy CSS in your theme’s stylesheet. { 

Source: Michael Martin

Recent Articles

How to Add Popups in WordPress?

Do you want to increase your website's conversion rate? Popup is an effective marketing tool for generating leads and it has a...

What is an XML Sitemap? How to Create a Sitemap in WordPress?

An XML sitemap is helping engines like google simply navigate thru your web site content material. It provides them a listing of your whole...

Vintage iPhone Film Camera Apps that you need to use in 2020

The iPhone has a great camera and it keeps getting better with every new version of the phone. Have you noticed how...

Transfer Your Data From Your Old iPhone to Your New iPhone

Want to buy a new iPhone this season, but don’t want to do all the work of transferring your data. Well, I...

Best Tools and Resources to Write Professionally for Everyone

Writing is considered the best medium to communicate your views, cause unlike speaking you can edit and improve. Written communication provides the...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here