WordPress Snippet : Searchbox
Wednesday September 28, 2005
I have started to add it into the themes I have designed and am designing, a little twist on the basic searchbox that comes with many WordPress themes. Generally, it’s the searchform.php that you work with, putting a simple form there with an input box and a search button.
So on mine there is no search button as many people realize that the enter button functions as one. Here is the code:
<form method=”get” id=”searchform” action=”<?php echo $_SERVER['PHP_SELF']; ?>”>
<div>
<input type=”text” value=”Search this blog…” name=”s” id=”s” onclick=”this.value=””
onblur=”if(this.value.length<1)this.value=’Search this blog…’;” />
</div>
</form>
When you click inside the box it resets to an empty box, and, if there is no text typed into the box, it will reset to the default value. Yes, the ampersand (&) lt; inside the code is supposed to be there, it allows the code/page to validate as XHTML.










Comments • [feed]
Comment 1
Thanks!
This will come in handy, if I ever make the Search and 404 pages.
MacBros commented on September 28th, 2005
Comment 2
Now aren’t you clever? LOL well OK we already knew that
Diane commented on September 28th, 2005
This blog requires you to login before replying. If you do not have an account you can create one (for free!).