Support » Fixing WordPress » Customize Search Widget Placeholder Text

  • Resolved BX12

    (@b-p)


    How do I change/customize the WordPress search widget placeholder text? From default “Search this site…” to text of my choice e.g. Press “Enter” to search…

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Steven Stern

    (@sterndata)

    Support Team Volunteer

    Here’s a snippet. Put it in your functions.php file

    function wpforo_search_form( $html ) {
    
            $html = str_replace( 'placeholder="Search ', 'placeholder="Press ENTER to search ', $html );
    
            return $html;
    }
    add_filter( 'get_search_form', 'wpforo_search_form' );

    Steve: That code messed up my site design globally. 🙁

    Moderator Steven Stern

    (@sterndata)

    Support Team Volunteer

    In what way?

    My mistake, Steve. I tried it again and it works! It now says “Press ENTER to search this website…” I’d like to trim that down to “Press ENTER to search…” Can you please tell me how? Thank you!

    Moderator Steven Stern

    (@sterndata)

    Support Team Volunteer

    Change the text on the left of the str_replace to match what you want to replace.

    The format (‘this’, ‘that’) is to replace this with that.

    Steve, Thank you for all your help. Brad

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Customize Search Widget Placeholder Text’ is closed to new replies.