Add search box to page

Is there a way to display a search box on a page (resembling the google landing page)?

I have tried to create a search page template. However, this doesn’t work as all the wp-template styling disappears.

Read More

Thanks

Related posts

Leave a Reply

1 comment

  1. You can do this using the get_search_form() function. For your custom parameters you can add some hidden fields or you can modify the action attribute value.

    The following can be considered as your form layout.

    <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
        <div><label class="screen-reader-text" for="s">Search for:</label>
            <input type="text" value="" name="s" id="s" />
            <input type="submit" id="searchsubmit" value="Search" />
        </div>
    </form>
    

    You can add your own parameters such as tags, etc. by appending the get parameters to the action attribute of form.

    Refer some examples below:

    1. WordPress Codex
    2. WP Beginner