SearchWP Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP’s many hooks

Automatic “Did you mean” (search query corrections)

A popular feature of some search engines is their ability to automatically apply corrections to search queries when no results are found for the original query.

To enable this functionality in SearchWP, enable the Closest Match option on the General Settings page:

Screnshot of SearchWP General settings

Alternatively this can be enabled with the searchwp\query\output_suggested_search hook.

When this feature is enabled, SearchWP will automatically attempt to correct any searches that provide zero results in addition to outputting a notice above The Loop of your search results:

⚠️ Style (CSS) customization is likely required ⚠️

Screenshot of SearchWP's "Did you mean?" automatic output

The above screenshot outlines the automatic output in Twenty Nineteen, a default WordPress theme. The following CSS can be added to improve its appearance:

Note: (You can add Custom CSS to your site by navigating to Appearance > Customize > Additional CSS in your WordPress Dashboard)

.searchwp-revised-search-notice {
margin: 0 calc(10% + 60px) 1em;
padding: 0.6em;
background: #f7f7f7;
border: 1px solid #e7e7e7;
border-radius: 2px;
}
.searchwp-suggested-revision-query {
font-style: italic;
font-weight: bold;
}
view raw style.css hosted with ❤ by GitHub

Which results in a notification that better matches the site design:

Screenshot of customized styling of SearchWP's "Did you mean?" automatic output

Interoperability with partial matches

When “Did you mean?” functionality is enabled and partial matching is enabled, SearchWP will first attempt to find exact partial matches and utilize partial match functionality.

If no partial matches are found, SearchWP will then utilize its “Did you mean?” functionality, determining the best search correction it can. If no search correction can be determined, SearchWP will show zero results.

Create a Better WordPress Search Experience Today

Never lose visitors to unhelpful search results again. SearchWP makes creating your own smart WordPress search fast and easy.

Get SearchWP Now
Multiple Search Engines Icon