Instantly share code, notes, and snippets.

Embed
What would you like to do?
508 compliant Genesis search form
<?php
//* Do NOT include the opening php tag
//* Alter the Genesis Search for so that we can change the destination page and our querystring parameter.
add_filter( 'genesis_search_form', 'b3m_search_form', 10, 4);
function b3m_search_form( $form, $search_text, $button_text, $label ) {
$onfocus = " onfocus=\"if (this.value == '$search_text') {this.value = '';}\"";
$onblur = " onblur=\"if (this.value == '') {this.value = '$search_text';}\"";
$form = '<form role="search" method="get" class="searchform search-form" action="' . home_url() . '/search">
<label class="search-form-label screen-reader-text" for="q">Search this website</label>
<input type="text" value="' . esc_attr( $search_text ) . '" name="q" id="q" class="s search-input"' . $onfocus . $onblur . ' />
<input type="submit" class="searchsubmit search-submit" value="' . esc_attr( $button_text ) . '" />
</form>';
return $form;
}
@carasmo

This comment has been minimized.

Show comment
Hide comment
@carasmo

carasmo Jan 18, 2016

Thank you for this!

carasmo commented Jan 18, 2016

Thank you for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment