Today’s Thesis recipe is a quick and simple fix that adds the WordPress search function to the Thesis header. As with any Thesis customization, you’ll need to have the custom_functions.php and custom.css files open.
Step 1 – Add the Search function
Open your custom_functions.php file and copy the following code into it:
function custom_search_widget() { ?>
<div class="widget widget_search">
<form method="get" class="search_form" action="<?php bloginfo('home'); ?>/">
<p>
<input class="text_input" type="text" value="Enter search..." name="s" id="s" />
<input type="submit" id="searchsubmit" value="Search" />
</p>
</form>
</div>
<?php }
add_action('thesis_hook_header' , 'custom_search_widget');
To break this down, you’re creating a custom function (custom_search_widget), you’re adding the WordPress search form and you’re telling Thesis (by means of a hook) to add the custom function to the Thesis header.
EDIT: You could also use the ‘thesis_search_form’ function that’s built in to Thesis, which would mean you can skip this function code altogether and simply add the action. I forgot about that one. Only catch is, it doesn’t have a submit button.
Step 2 – Style the Search function
Your search function will work just fine, but it looks lousy. If you’d like to clean it up and e.g. position it on the right hand side of your header, add the following to your custom.css file:
/* clears the header floats */
#header {
overflow: hidden;
}
/* allows the search function to be positioned to the right of the logo */
#logo, #tagline {
float: left;
width: 300px;
}
/* places the tagline below the logo */
#tagline {
clear: left;
}
/* positions the search widget on the right hand side of the header */
.widget_search {
float: right;
width: 200px;
}
/* formats the search input and button */
.search_form .text_input {
font-size: 11px;
padding: 5px;
}
.search_form #searchsubmit {
font-size: 11px;
padding: 4px;
}
There you have it. Obviously you can style your search form to match your theme, but the bare-bones are here. All that’s needed now is your imagination (and some CSS skills).
If you think these short tutorials are useful or you’d like to request a Thesis recipe, please let me know.





Hello, I’m Dave. I work with web design agencies, freelancers and bloggers to develop standards-compliant WordPress and Thesis themes.
{ 3 comments }
This is great Dave. We really need these straightforward tutorials for Thesis.
.-= Kim Woodbridge´s last blog ..Upcoming Facebook Changes to Boxes and the Box Tab that Will Impact Your Custom Fan Pages =-.
Hi Kim, I think that it’s these simple customization elements that keep people from exploring Thesis further. Hopefully 100 or so of these tutorials will help the Thesis community to muster up some unique designs
An excellent tutorial, and it actually works! I’ve had an unhealthy obsession about getting a search submit button into my Thesis themed blog — http://moderncomfortfood.com — since, oh, the day I installed Thesis. And each attempt failed until I saw your tutorial above.
I have a couple of follow-up questions though:
1) I want the Thesis search form to stay in its default widget position in the sidebar. But substituting “thesis_hook_before_ sidebar_1″ bumps the search form to the top of the sidebar, where I don’t want it. Any ideas about how I can get the custom.php to apply to the default widget without actually moving it?
2) I’ve tried various iterations of substituting a 24px x 20px .gif search image for your search submit button — a la background: url (http://…. It’s not quite working. Any ideas?
.-= barbara´s last blog ..Turkey or Chicken Divan =-.
Comments on this entry are closed.