WordPress Search Theme Tutorial

    By: Thad Mertz
    3 years ago

    To include search in your custom theme just add below given code in the header file of your theme.

    Then refresh the page to have search field. It is a wordpress function to include search.

      get_search_form();
    

    To customize the search field you can create "searchform.php" and have form code in this file. Check this form code here

    <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
        <div>
            <input type="text" value="" name="s" id="s" placeholder="<?php echo the_search_query(); ?>" />
            <input type="submit" id="searchsubmit" value="Search" />
        </div>
    </form>
    

    You can edit it as you like and even can have label included.

    Now search result page can be customized as well for that in your theme create "search.php" file. You can use the code from "index.php". and then can edit it as you wish.

    Hope this guide helps, If have doubts check our video guide.