facetwp filter wp search form


{{gist file=”custom-hooks.php” lang=”php”}}

/** filters search form to replace the s input with your search facet – change fwp_search as needed
** and replace the default action with the page url of your custom search results page – change /search-results/ as needed
** may need adjusting if the search is already modified by another plugin or theme */

add_filter( ‘get_search_form’, function( $form ) {
$form = str_replace( ‘name=”s”‘, ‘name=”fwp_search”‘, $form );
$form = preg_replace( ‘/action=”.*”/’, ‘action=”/search-results/”‘, $form );
return $form;
} );