How to create a custom WordPress search form

WordPress already offers a default get_search_form() function that can be reproduced in any part of the template, but that is constrained to the designed offered by the WordPress core team. Limiting to that design will be an injustice to the highly customizable WordPress content management system.

There is an easy fix.

Step 1: Create a searchform.php file in your root directory of the theme, and

Step 2: Put your custom form there. Here we have given an example:

<form class="tform" id="searchform" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>">
  <div class="tinput">
    <input class="email-search-box" name="s" size="40" type="text" placeholder="Search"/><input class="email-search-btn" value="Search" type="submit"/>
  </div>
</form>

Leave a Reply

Your email address will not be published. Required fields are marked *