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

Charge Your Laptop Without a Charger in 5 Ways

Forgetting your laptop charger is a pretty common thing. We all have been there and all of...

Mobile-Only Bank versus Traditional Banks, Which one is for you?

Transactions over the internet are nothing new, online money transfer has been a part of our lives...

5 Reasons Behind The Slow Performance of Your iPhone

iPhone is a rather fast device, famous for its high level of performance. Most iPhone users define...

5 Apps to Use During Pregnancy for Android Users

Human birth is often described as the most beautiful phenomenon on the planet, but it could be equally as painful for the...

4 Best Apps to Teach Children to Read and Write at Home

Writing and reading are the two most basic skills that are taught to a kid. Though basic...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here