Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vbaimas/62e65ce7ded7fae5501d90eed3b5a6f8 to your computer and use it in GitHub Desktop.
Save vbaimas/62e65ce7ded7fae5501d90eed3b5a6f8 to your computer and use it in GitHub Desktop.
In case you want to change the default word “Search” in the Search Button, into something different, this snippet will allow to change it.
/*/
/* Change Search Button Text
/*/
add_filter('get_search_form', 'my_search_form');
function my_search_form($text) {
$text = str_replace('value="Search"', 'value="ok"', $text); //set as value the text you want
return $text;
}
@vido89
Copy link

vido89 commented Jun 18, 2025

Awesome thank you for sharing ! Could you help me to replace `placeholder="Search …" with custom text

<input type="search" class="search-field" placeholder="Search …" value="" name="s">

@vido89
Copy link

vido89 commented Jun 18, 2025

So if you want to replace placeholder in search field here is code

/**
 * Replace the search form placeholder text.
 *
 * @param string $form The HTML markup of the search form.
 * @return string
 */
function my_custom_search_placeholder( $form ) {
    // Replace the default placeholder
    $form = str_replace(
        esc_attr_x( 'Search &hellip;', 'placeholder' ),
        esc_attr__( 'Find on my blog …', 'text-domain' ),
        $form
    );
    return $form;
}
add_filter( 'get_search_form', 'my_custom_search_placeholder' );

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