Site logo

Archived topic

"Search Form" Text Hover

3 replies · Started by Feri on July 27, 2018

Viewing posts 1–4 of 4

Hi,

i have this snippet code to change text on search form. work perfectly.


add_filter( 'generate_search_placeholder', 'tu_change_search_title' );
function tu_change_search_title()
{ 
    return 'Search Post...';
}

but i want to also change text when mouse cursor currently on search form / hover text? the default text is "Search for:".

what code should i change / add to my previous snippet?

Thank you

Try adding this as well:

add_filter( 'generate_search_label', 'tu_change_search_title' );

add_filter( 'generate_search_placeholder', 'tu_change_search_title' );
add_filter( 'generate_search_label', 'tu_change_search_title' );
function tu_change_search_title()
{ 
    return 'Search Post...';
}

like that? i dont know how to add this code. the text hover "search for" not change.

ss: http://prntscr.com/kc8tnb

Hmm, that definitely should have done it. Weird.

Try this instead:

add_filter( 'gettext', 'tu_change_search_text', 20, 3 );
function tu_change_search_text( $translated_text ) {
    if ( 'Search for:' === $translated_text ) {
        $translated_text = 'Your text here';
    }

    return $translated_text;
}
This archived topic is closed to new replies.