Adding Searchbox in wordpress anywhere

1. if your template supports it you can just add :
<?php include (TEMPLATEPATH . ‘/searchform.php’); ?>

2.adding the following code will put a text inside the search box.
(like “Write your search and hit Enter” )

<form method=”get” id=”searchform” action=”<?php bloginfo(‘home’); ?>/”>
<div><input type=”text” size=”put_a_size_here” name=”s” id=”s” value=”Write your search and hit Enter” onfocus=”if(this.value==this.defaultValue)this.value=”;” onblur=”if(this.value==”)this.value=this.defaultValue;”/>
<input type=”submit” id=”searchsubmit” value=”Search” />
</div>
</form>

and finally, combining those two advices, just save the code from part two as searchform.php in your template folder, and you can always call it with method number 1.

Advertisements
This entry was posted in Wordpress. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s