Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To highlight a visitor’s search terms in WordPress results, use a highlighting plugin, Relevanssi’s highlighting features, or adjust the search-results template and CSS. The right fix depends on where the text should be highlighted and whether your results template actually displays the excerpt or title output the highlighting feature modifies.

Choose a highlighting method

Method Best for What to check
Highlight Search Terms plugin Adding visual highlighting to search results and the linked post page Whether your theme has a recognized content container, and whether you need to add CSS
Relevanssi Sites already using Relevanssi, or sites that also need its search features Whether the result template calls the_excerpt() and, for title highlighting, uses relevanssi_the_title()
Template or CSS customization Results whose theme or query loop does not output the text handled by a plugin The actual source of the displayed title or excerpt and the markup available for styling

Highlighting by itself does not require Relevanssi Premium: Relevanssi lists match display and highlighting in both its Free and Premium editions. Compare other features separately before choosing a tier (Relevanssi features and benefits).

Use the Highlight Search Terms plugin

The WordPress.org listing says the plugin finds search terms in each post on the search-results page and wraps them in <mark class="hilite term-N"> elements. It also supports highlighting on the linked post page, matches without regard to character case, and treats quoted phrases as one term. The listing describes the plugin’s behavior; it does not provide a settings page or predefined CSS styling (Highlight Search Terms on WordPress.org).

Check the content container

The plugin relies on theme markup to identify post content. A recognized wrapper such as article or .hentry helps keep matching within the result content. If your theme does not use a recognized container, the script may scan a broader area and highlight matching words in navigation or other surrounding page content.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add styling if needed

The plugin supplies the markup, not a visual design. If your browser or theme does not make <mark> stand out as desired, add a CSS rule for .hilite in your theme’s custom CSS area. For example:

.hilite {
  background-color: #fff2a8;
  color: inherit;
}

Choose colors that remain readable against both the text and the page background.

Use Relevanssi for excerpts, titles, and arbitrary text

Relevanssi can highlight search terms in generated excerpts and titles, and it provides a function for applying highlighting to other text. Its custom result snippets are generated dynamically during the search loop, so the results template must call the_excerpt() for those snippets to appear. For title highlighting, replace the_title() with relevanssi_the_title(). To preserve the query for highlighting after a visitor opens a result, use relevanssi_get_permalink() for the link (Relevanssi installation and settings).

Highlight other text with the function

relevanssi_highlight_terms($content, $query, $convert_entities = false) can apply highlighting to arbitrary text when you provide the content and search query. Available markup styles include mark, strong, em, colored or background spans, a CSS-style span, a class, or no markup. Settings determine matching and entity handling. When processing full post content containing HTML that should be preserved, set the third parameter to true; excerpt text has different entity handling. See the Relevanssi function reference for the function’s details.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Diagnose results that do not highlight

If a plugin is active but search terms remain unmarked, first identify where the visible result text comes from. A search-results template may bypass the excerpt or title output that a highlighting feature expects. This can happen with a block-based query loop, but behavior depends on the theme and implementation: a WordPress.org support thread reports a GenerateBlocks Query Loop case and suggests it may use a different excerpt source; it does not establish that all block themes behave the same way (WordPress.org support discussion).

  • Excerpt is missing highlights: If using Relevanssi, check whether the result template calls the_excerpt().
  • Title is missing highlights: If using Relevanssi, check whether the template uses relevanssi_the_title() instead of the_title().
  • Unexpected areas are highlighted: Check whether your theme wraps post content in a recognized element such as article or .hentry.
  • Markup appears but looks plain: Add or adjust CSS for the highlighting class.
  • A block query loop does not show the expected snippet: Inspect the loop’s actual excerpt source and output rather than assuming it uses the same template path as a conventional search result.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.