Helping you build a better website
(and other interesting web stuff)

CSSHTMLJavaScriptjQueryMSSQLMySQLPHPSilvaTechnologiesWordpress
Silva Web Designs - Blog

How to Change the Placeholder text for the WordPress Search Form

Today we will learn how to change the placeholder text for WordPress search forms.

To display a WordPress search form you can use the following PHP code:-


<?php get_search_form(); ?>

Now, we just need to add the below code to your functions.php /** * Search Form */ function wp_search_form( $form ) { $form = '<section class="search search-form"><form role="search" method="get" action="' . home_url( '/' ) . '" > <label class="screen-reader-text" for="s">' . __('', 'domain') . '</label> <input type="search" class="search-field" value="' . get_search_query() . '" name="s" id="s" placeholder="" /> <input type="submit" id="searchsubmit" class="search-submit" value="'. esc_attr__('Go', 'domain') .'" /> </form></section>'; return $form; } add_filter( 'get_search_form', 'wp_search_form' );

We hope this article has helped you to be able to change the placeholder text for the WordPress search box.

Are you wanting to customise the default WordPress Search?

You may also be wondering how you can customise the default search to only display certain things. For example, you may not want to search for posts, but only display pages or certain CPT (Custom Post Types). This can also be done bespoke, but we tend to find the Relevanssi – A Better Search plugin to do the job perfectly well, and safe quite a bit of time. Relevanssi replaces the standard WordPress search with a better search engine, with lots of features and configurable options. You'll get better results, better presentation of results and your users will thank you.

If you need assistance with setting this up, feel free to get in touch, we look forward to hearing from you.

Nathan da Silva - Profile

Posted by: Nathan da Silva

Nathan is the Founder of Silva Web Designs. He is passionate about web development, website design and basically anything digital related. His main expertise is with WordPress, Magento, Shopify as well of many other frameworks. Whether you need responsive design, SEO, speed optimisation or anything else in the world of digital then get in touch. If you would like to work with Nathan, simply drop him an email at [email protected]

It’s good to share

Join the discussion