Changing the “Search” string in WordPress search forms

⚠️ Code snippets might not be compatible with the latest version of your theme. Always use a child theme to customize your theme, and test your code on a staging website before migrating to production.

You can search the user’s forum or ask the user community by opening a new thread in the Customizr theme forum. Before opening a new topic, you might want to follow the troubleshooting steps..

 

Note about translations : before you start coding anything, note that the “Search” string in the search forms is a WordPress string. If this string is not translated in your language, make sure you update your WordPress language translation on WordPress Polyglots.

 

In case you want to change the default word “Search” in the Search Button, into something different, this snippet will allow to change it.
Just paste this function into your child-theme functions.php file.

/*********************************/
/* Change Search Button Text
/**************************************/

// Add to your child-theme functions.php
add_filter('get_search_form', 'my_search_form_text');
 
function my_search_form_text($text) {
     $text = str_replace('value="Search"', 'value="Click me"', $text); //set as value the text you want
     return $text;
}

Note: the ‘value=”Search”‘ needs to be replaced accordingly to the default WP language installation:
‘value=”Cerca”‘ for Italian
‘value=”Suche”‘ for German and so on…

Where to copy/paste this code?
Add it to your child-theme functions.php and to your style.css.
Everything you need to know about creating a child theme with Customizr here.

Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “Changing the “Search” string in WordPress search forms”