Created
November 22, 2012 05:44
-
-
Save rianrietveld/4129586 to your computer and use it in GitHub Desktop.
WordPress Genesis searchform with label and hook for genesis_header_right
This file contains hidden or 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
.prefix-hidden { | |
background-color: #fff; | |
border: 1px solid #000; | |
display: block; | |
font-size: 1em; | |
left: -1000em; | |
padding: 0.8em; | |
position: absolute; | |
z-index: 10; | |
} | |
.hidden:focus, .hidden:active { | |
top:1em; | |
left:1em; | |
z-index:1000; | |
color: #1E6891; | |
} |
This file contains hidden or 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 | |
/** | |
* WordPress Genesis Accessible searchform for the header | |
* Rian Rietveld - rrwd.nl | |
* Add this to the functions.php in your child theme for the Genesis Framework by StudioPress. | |
* This function replaces the search form with a more accessible one by adding a hidden label | |
*/ | |
add_action ('genesis_header_right' , 'prefix_header_search_and_sitemap'); | |
function prefix_header_search_and_sitemap() { | |
?> | |
<form method="get" class="searchform" action="<?php echo home_url('/')?>"> | |
<label for="s" class="prefix-hidden">Search this site</label>.txt | |
<input type="text" value="Search this website …" name="s" class="s" onfocus="if (this.value == 'Search this website …') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search this website …';}"> | |
<input type="submit" class="searchsubmit" value="Search"> | |
</form> | |
<?php | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello. This search form is HTML5 compliant? Thanks in advance. Joan