Override search form layout in WordPress

You can override default layout of search form in wordpress. It is easy in WordPress. In your theme where you want search form in your custom html code then first add this code.

<?php get_search_form(); ?>

This function first search the ‘searchform.php’ template file in our theme. We can add our custom html design and css code in ‘searchform.php’ to change its layout.
If ‘searchform.php’ not found in theme then this function use default search form code for example :

<form role="search" method="get" class="search-form" action="index.php">
<span class="screen-reader-text">Search for:</span>
<input type="search" class="search-field" placeholder="Search &hellip;" value="" name="s" title="Search for:" />
<input type="submit" class="search-submit" value="Search" />



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s