Site icon Nabtron

How to add search bar to wordpress blog theme

In this tutorial we will discuss how to add a search bar to your wordpress theme. This is useful if u need a search bar / form to be added to your own custom wordpress theme, or if you are using some other theme, and want to add a search form in it.

One way it to enable the search option from the wordpress admin > appearence > widgets and the dragging the search form widget to the right selection box. However, if you want to add the search form to any other specific place in your wordpress theme, such as header, you can follow this:

Goto wordpress root dir > wp-content > themes > [your theme] > header.php

There, select the area where you want to add the search box, and simply copy this code there:

<form id="searchform" method="get" action="/index.php">
<input type="text" name="s" id="s" size="15" />
<input type="submit" value="Search" />
</form>

This is the minimum code that you need to be added there.

However if you need some styling, then use this code , and / or modify it or the above code to suit your needs. You need to know html and css to edit and modify this code.

<div id="searchone" style="float: right;width: 200px;padding: 10px;">
<form id="searchform" method="get" action="/index.php">
<div>
<input type="text" id="searchtopone" name="s" id="s" size="20" />
<input type="submit" id="searchgoone" value="Go" />
</div>
</form>
</div>

I added this code to the end of pages code in the header of my wordpress theme, so that it appears in the header bar, as a search bar in the line of pages links for my wordpress blog.

Exit mobile version