Skip to content

Instantly share code, notes, and snippets.

@sethrubenstein
Created April 26, 2014 22:30
Show Gist options
  • Save sethrubenstein/11332891 to your computer and use it in GitHub Desktop.
Save sethrubenstein/11332891 to your computer and use it in GitHub Desktop.
Proper WordPress Search Box
<?php
/**
* Theme Default Search Box
*/
?>
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<div id="searchsubmit" class="dashicons dashicons-search" /></div>
<input type="search" value="" name="s" id="s" placeholder="Search"/>
<input type="submit" id="submitsearch" value=""/>
<script>
jQuery(document).ready(function($) {
jQuery( "#searchsubmit" ).on( "click", function() {
jQuery( "#submitsearch" ).trigger( "click" );
});
});
</script>
</form>
#searchform {
input[type="search"] {
resize: none;
}
input[type="submit"] {
height: 0px;
padding: 0px;
width: 0px;
opacity: 0;
}
#searchsubmit {
position: relative;
float: right;
margin-bottom: -20px;
padding-top: 8px;
margin-right: 10px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment