Adding a search form to WordPress is actually quite simple. All you need to do is create a new file add some code and than place a line of code where you want your search form to appear. Below you will find the code needed for the searchform.php file and how to make the search form appear on your site.
First thing you will need to do is create a searchform.php file using a text editor and paste the following code:
<form method=”get” id=”search-form”
action=”<?php bloginfo( ‘home’ ); ?>/”>
<input type=”text”
value=”" name=”s” id=”searchinput” />
<input type=”submit” id=”searchsubmit”
value=”Search” />
</form>
Once you have created your searchform.php file you will have to add it to your theme’s folder (the wp theme you intend on using). If you haven’t uploaded this theme to your server do it, otherwise you can drag your searchform.php file into your theme’s folder on the server.
Next you will have to call this file in order to show the search box.
Now that you have your searchform.php file you will want to make a call to the searchform from wherever you want on your theme file (Maybe the sidebar? The header?). Open your theme file of choice and past the following where you want your search box to appear:
<?php include (TEMPLATEPATH . ‘/searchform.php’); ?>
This post is intended for advanced users, so I assume you know hot style this search form. But basically, you will want to style the following id’s “search-form”, “searchinput” and “searchsubmit” via your stylesheet.css so you can achieve the look you want for your search bar.
I’ve not added any search form on my blog. Thanks for your tutorial =)
I wound up using Google Docs form embedded for my wordpress contact form, was an easy way to leverage same form for all blogs plus track in one document. I wrote a post and did a video presentation on my site on how to do this.
That’s a really great idea. I would love it if you could share the tutorial and video on WPExplorer.com.
i have no idea how it will come out in the browser… isn’t there any sample screenshoot?
Sorry, I wrote this post a long time ago for a friend that had a stronger knowledge of web development.
You need to upload the .php file to the folder of the theme you are using.