How to Add a Search Bar in wordpress blog

How to Add a Search Bar in wordpress blog ? The answer is here . This code will be helpful for theme developers and for those who like to add search to their wordpress blog . Follow the below steps and your Blog search will be ready in 5 minutes .

1] Create a New PHP file named ” searchform.php “

2] Add the following code :

<form method=”get” id=”searchform” action=”<?php bloginfo(‘home’); ?>/”>
<div><input type=”text” size=”18″ value=” ” name=”s” id=”s” />
<input type=”submit” id=”searchsubmit” value=”Search” class=”btn” />
</div>
</form>

3] Save the above code in searchform.php , and upload it to your Theme Folder .

4] Now include , <?php include (TEMPLATEPATH . ‘/searchform.php’); ?> ,  where ever you like in your theme .

Preview :



Related Posts :

Whats Next ?



  1. [...] Vote How to Add a Search Bar in wordpress blog [...]

  2. Josh Fialkoff on 22 November 2008

    Nice post!

    What do you think of Google site search (“custom search engine”)?

    I’ve found it to be easy to install… you can see how it works on my site– and how it fits in with the 404 page (such as http://www.nooozeguy.com/fialkoff for instance).

    Thanks,
    -Josh

  3. Allison Sellers on 25 November 2008

    Awesome site, I am going to read more of your posts soon.

  4. Matt on 15 August 2009

    Thanks for the great tut!

    Very simple and easy to implement. I might add that you can easily style the output by adding a class or ID to the div tag.

    I’m definitely using this on my site!

  5. Pedro on 4 September 2009

    Thanks for your post.

    my site has a problem, when I or other person search, you don´t get results. it happens with all themes.
    The site is in other language but the error is easy to see.

    do you have any tip to resolve this kind of problem?

    site: http://www.apostei.net

    Thanks in advance

  6. Richard Scott on 20 September 2009

    <form method=”get” id=”searchform” action=”/”>

    Hi
    I’m way too new to this :)
    What above text do I modify per direction/pages from my site?
    I would like to insert a search bar at
    http://www.thewantlist.ca/collectors/
    I want the bar to search pages on my site – ie – a user types in “Parkies” or “1951-52″ and they get the following page:
    http://www.thewantlist.ca/hk19512_parkhurst/

    Thank you
    Richard Scott

  7. federico on 2 January 2010

    Great info, very easy to implement. See how it looks in my travel blog maitravelsite.com