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 Tabs to WordPress Posts and Pages

Tabs effectively organizes the content and engages the user. You can divide your posts into tabs in order to save space and...

How To Check Whether Someone Blocked You On Instagram

All social media platforms including Instagram do not notify people when they get blocked by a user. But when someone’s post and...

Free Apps Make Money through These Innovative Ways

Have you always wondered why are some apps available to you free of cost? If you want to know how apps make...

How To Completely Remove Google Account From Chrome Browser

Google Chrome when used with your personal Google account lets you keep the data in sync with all your devices. Your YouTube...

How To Know If Your Android Smartphone Is Hacked And How To Fix It!

One of the worst nightmares you can ever witness is realizing that your Android Smartphone Is Hacked. Yes, you're allowed to be...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here