Skip to content

Instantly share code, notes, and snippets.

@topleague
Created March 4, 2018 11:17
Show Gist options
  • Save topleague/3953882debac034322f7b174d835435e to your computer and use it in GitHub Desktop.
Save topleague/3953882debac034322f7b174d835435e to your computer and use it in GitHub Desktop.
Functions Code for Google Custom Search Engine In Genesis
//* Alter the Genesis Search to change the destination page and our querystring parameter.
add_filter( 'genesis_search_form', 'leaguewp_search_form', 10, 4);
function leaguewp_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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment