Enabling Search box in WordPress frontend template

Search box in wordpress is a widget. A widget is a PHP object that outputs some HTML. The same kind of widget can be used multiple times on the same page (e.g. the Text Widget). Widgets can save data in the database (in the options table).

When you create a new kind of widget, it will appear in the user’s Administration Screens at Appearance > Widgets.

A set of widgets is included with the default WordPress installation. In addition to these standard widgets, extra widgets can be included by themes or plugins. An advantage of widgets built into themes or plugins is to provide extra features and increase the number of widgets.

  1. Make sure the current template is widget aware. ie having sidebars. if the current template is not widget aware , you may
    1. follow the steps in https://developer.wordpress.org/themes/functionality/widgets/ or
    2. replace existing template witha widget aware template
  2. Follow the steps bolow in a widget aware template
    1. Go to your Admin Dashboard.
    2. Navigate to Appearance > Widgets. Here, you'll find the widget named Search under the Available Widgets.
    3. Click on it and then hit the Add Widget button. You can also drag it to the Widget Area. You can add the title for your search widget if required.
    4. Now go to your site and you'll see the Search widget on the sidebar.