SearchWP

This Documentation is for SearchWP Version 3

Available since: 3.1

searchwp_auto_output_revised_search_query

View Parameters »

When Automatic “Did you mean” (search query corrections) or Quoted (Phrase, Sentence) Search Support has been enabled either on the Advanced tab of the SearchWP settings screen or using a hook (searchwp_do_suggestions and searchwp_allow_quoted_phrase_search, respectively) SearchWP will automatically output a notice at the top of The Loop indicating that a search query has been revised.

This happens only when search query corrections have been enabled, but you can prevent that from happening by adding this to your theme’s functions.php:

<?php
// Prevent SearchWP from outputting notice about search query corrections.
add_filter( 'searchwp_auto_output_revised_search_query', function( $enabled, $args ) {
// $args contains the search query arguments for the search
// $args['type'] will be 'did-you-mean' for "Did you mean?" corrections
return false;
}, 10, 2 );
view raw functions.php hosted with ❤ by GitHub

With this snippet in place, automatic output of SearchWP’s notice will no longer take place, and you can use the searchwp_revised_search_query action to output your own notice:

<?php
// Output a custom notice when SearchWP finds a search correction.
add_action( 'searchwp_revised_search_query', function( $args ) {
// TODO: Output a notice indicating a search correction has been made.
});
view raw functions.php hosted with ❤ by GitHub

Note: The $args passed along with the hook will contain a type key that indicates whether a “Did you mean?” or quoted search fallback has taken place.

Parameters

Parameter Type Description
$enabled Boolean

Whether automatic output happens

$args Array

Search query arguments

[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]