Celebrate Our 22nd Anniversary with Huge Savings! Up to 70% Off

How To Highlight Search Terms In WordPress?

Would you like to make WordPress search results more user-friendly?

Highlighting search terms in your site’s search results helps visitors quickly find exactly what they need. This simple enhancement can improve navigation, increase page views, and extend session durations—ultimately enhancing user experience and engagement.

 

How To Highlight Search Terms In WordPress

 

Method 1: Highlight Search Terms In WordPress Using cPanel

1. Log into your cPanel account.

2. Navigate to Files > File Manager.

 

 

3. Inside your public_html, you will find wp-content > themes > your active theme > patterns.

4. Search for the search.php file.

 

 

5. Look for the following code:

 
<?php the_title(); ?>
 

6. Replace the above code with the following code:

 
<?php echo $title; ?>

<?php $title = get_the_title();
$keys= explode(" ",$s); $title = preg_replace('/('.implode('|', $keys) .')/iu', '<strong
class="search-excerpt">\0</strong>', $title); ?>
 

Open your CSS file and add styling for the .search-excerpt class to highlight the search terms. Right now, the code makes the search terms bold, but you can customize it further. Simply add this CSS to your theme’s stylesheet to see the effect.

strong.search-excerpt {

background-color:yellow;

color:blue;

}

 
Enhance your website’s efficiency with WordPress Hosting, ensuring smooth performance, quick load times, and seamless site management.
 

Method 2: Highlight Search Terms In WordPress from the WP Dashboard

 
Note: The page must be created with either Gutenberg or Elementor.
 

1. Log into your WordPress dashboard.

2. Navigate to Page and choose the page.

3. Next, explore the settings and navigate to the Results Area section.

4. Turn on the "Highlight Searched Text" toggle to enable the feature.

 

 

5. Click Publish or Update to save your changes.

 

Method 3: Highlight Search Terms In WordPress Using a Plugin (paid plugin)

 
Note: After purchasing, you can download the plugin file from the "Downloads" section in your SearchWP account.
 

1. Log into your WordPress dashboard.

2. Go to the Plugin > Add New Plugin.

3. Search for the SearchWP plugin.

4. Click on Install Now and activate it.

 

 

5. Go to SearchWP > Add License Key.

6. Copy your license key from the Downloads section in your SearchWP account and paste it.

7. Click "Verify Key" to activate your plugin.

 

 

8. Once verified, your license details will appear below.

9. Go to SearchWP > Settings in your WordPress dashboard.

10. Scroll to the General Settings section and find "Highlight Terms."

11. Toggle the switch ON to enable this feature.

 

 

Before installing any WordPress plugin, it's recommended to check user reviews and ensure compatibility with your WordPress version before installing.

 
 

Was this answer helpful?

« Back

chat