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.

sturdy.search-excerpt { 
background-color:yellow;
coloration:blue;
}

Source: Michael Martin

Recent Articles

The New Apple Music Features to Definitely Try in 2021

Apple Music is a nice app but it is not the most loved app, even among Apple users. The wide range of...

Best Free News Apps for iPhone and iPad in 2021

The year isn’t going as we expected, we are still living through a pandemic and all the problems of the world didn’t...

Best Apps to Hide Pictures & Videos on Your Phone

Privacy is important in everyone’s life, the intensity might change but no one wants to share everything with the world. Even the...

5 Best Health Apps for a Healthy Lifestyle for Everyone in 2021

Times have changed, but the only thing that has remained constant is the need for a healthy lifestyle. Various factors contribute to...

The Most Exciting Features of Apple iOS 14.5 for iPhone and iPad

The Most Exciting Features of Apple iOS 14.5  Apple tries to bring something new and better with every iOS...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here