[Resolved] "Search Form" Text Hover

Home Forums Support [Resolved] "Search Form" Text Hover

Home Forums Support "Search Form" Text Hover

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #634440
    Feri

    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

    GP Premium 1.6.2
    #634665
    Tom
    Lead Developer
    Lead Developer

    Try adding this as well:

    add_filter( 'generate_search_label', 'tu_change_search_title' );

    #634944
    Feri
    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

    #634989
    Tom
    Lead Developer
    Lead Developer

    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;
    }
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.