Last active
April 26, 2020 15:39
-
-
Save krasenslavov/1216fafa04bb5f1d38b3e91ebd2b1c70 to your computer and use it in GitHub Desktop.
Override WordPress get_search_form with plain HTML form. Visit blog post https://bit.ly/2XX2QLQ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generate custom search form | |
*/ | |
function my_search_form($form) { | |
$form = '<form role="search" method="get" id="searchform" class="searchform" action="' . home_url('/') . '"> | |
<div> | |
<label class="screen-reader-text" for="s">Search for:</label> | |
<input type="search" value="' . get_search_query() . '" name="s" id="s" /> | |
<input type="submit" id="searchsubmit" value="Search" /> | |
<datalist id="search"> | |
<option value="WordPress"></option> | |
<option value="WooCommerce"></option> | |
<option value="WordPress Plugins"></option> | |
<option value="WordPress Themes"></option> | |
<option value="Automattic"></option> | |
<option value="Widgets"></option> | |
... | |
</datalist> | |
</div> | |
</form>'; | |
return $form; | |
} | |
add_filter('get_search_form', 'my_search_form'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment