How to move the search bar in the Revolution Theme

It occurred to me that others may well be interested in further understanding how to customise their Revolution wordpress theme. The subject of this tutorial will be how to move the search bar from its current position in the image header area and put it into the navbar area.

At the moment there are instructions here which show how to make the image header a full width one, but it does so with the sacrifice of the search bar. My way is to keep the search bar but move it to a place that has less impact on the image at the top of your web page

What’s needed

Familiarise yourself with the style.css file

The syle sheet has been carefully designed and once you get past the code it is actually pretty straightforward. In this file you can alter all the various components that make up the look and feel of the theme. Each section has convenient descriptions attached to them like this one:

The header from the css file


There are ones for hyperlinks, header, navbar, homepage layout (generic page,) homepage bottom, content narrow, news page styling, featured page, Sidebar, Left sidebar, Footer (generic to all pages,) search form, and finally comments.

For the purposes of this tutorial, we are going to be dealing with the sections that relate to header and navbar.

The basics

1) First of all, if you have a live working version of the theme, download the style.css and header.php files from your server, make a copy of them and keep them somewhere safe. This way if you make a mistake, you can always go back to the working version

2) Open up style.css and scroll down to the header section and make the changes that can be found here. But don’t make the alterations to the header.php files just yet. Once you have done what Brian suggests, come back here but keep the style.css file you are editing, open.

3) Then scroll down to Navbar section where you will find:

#navbar {
background: #333333;
width: 920px;
height: 35px;
color: #FFFFFF;
margin: 0px auto 0px;
padding: 0px 0px 0px 0px;
border-top: 10px solid #FFFFFF;
border-bottom: 20px solid #FFFFFF;
}

#navbarleft {
width: 890px;
float: left;
margin: 0px;
padding: 10px 0px 10px 0px;
}

#navbarright {
width: 26px;
float: right;
margin: 0px;
padding: 10px 0px 0px 0px;

What this is saying is that the nav bar is 920px wide by 35px high. The left side is currently taking up 890px of that space and the right the remaining 26px as in the picture below:

Standard navbar in theme


4) If you were to scroll down the style.css file to ‘Search Form’ you would find the following text

s-head {
background: #FFFFFF;
width: 240px;
color: #333333;
font-size: 12px;
font-family: Arial, Tahoma, Verdana;
padding: 4px;
margin: 5px 0px 20px 0px;
border-top: 1px solid #666666;
border-right: 1px solid #DDDDDD;
border-left: 1px solid #666666;
border-bottom: 1px solid #DDDDDD;
}

What this means is that the search box is 240px wide. Now I want to put that search box into the navbarright element and at the moment the space is much smaller than I need. The search box is also a bit bigger than I want it as well

5) So to create the space, we need to change some of the values in the navbarright and left to this:

#navbarleft {
width: 740px;
float: left;
margin: 0px;
padding: 10px 0px 10px 0px;
}

#navbarright {
width: 180px;
float: right;
margin: 0px;
padding: 10px 0px 0px 0px;
}

6) So with that done we now need to make sure that search bar is the right size, so scroll down to:

s-head {
background: #FFFFFF;
width: 240px;
color: #333333;
font-size: 12px;
font-family: Arial, Tahoma, Verdana;
padding: 4px;
margin: 5px 0px 20px 0px;
border-top: 1px solid #666666;
border-right: 1px solid #DDDDDD;
border-left: 1px solid #666666;
border-bottom: 1px solid #DDDDDD;
}

and change the entire code to:

#s-head {
background: #FFFFFF;
width: 160px;
color: #333333;
font-size: 12px;
font-family: Arial, Tahoma, Verdana;
padding: 2px;
margin: 0px 0px 0px 0px;
border-top: 1px solid #666666;
border-right: 1px solid #DDDDDD;
border-left: 1px solid #666666;
border-bottom: 1px solid #DDDDDD;
}

This will make the search bar the right size and also give it the right amount of padding so that it sits nicely within the space you have made.

7) Ok save that file and lets move on to making the search bar appear correctly.

8. Open up your header.php file your favourite code editor. Scroll down and you will see something like this:

<div id="header">
<div id="headerleft">
<a href="<?php echo get_settings('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/logo.gif" alt="<?php bloginfo('name'); ?>" /></a>
</div>
<div id="headerright">
<b>Looking for something in particular?</b><br />
<form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" value="To search, type keywords and hit enter..." name="s" id="s-head" onfocus="if (this.value == 'To search, type keywords and hit enter...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'To search, type keywords and hit enter...';}" /></form>
</div>
</div>

As Brian says here you will need to change that section so that it says this:

<div id="header">
<a href="<?php echo get_settings('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/logo.gif" alt="<?php bloginfo('name'); ?>" /></a>
</div>

9) Then scroll down to the following section:

<div id=”navbarright”>
<a href=”<?php bloginfo(‘rss_url’); ?>”><img src=”<?php bloginfo(‘template_url’); ?>/images/rss.gif” alt=”Subscribe to <?php bloginfo(‘name’); ?>” /></a>
</div>

This deals with how the navbar is going to be displayed. At the moment it is showing the functions that relate to subscribing to RSS. We need it to show the search bar.

10) Change the code to the following:

<div id=”navbarright”>
<form id=”searchform” method=”get” action=”/index.php”
name=”searchform”>
<input type=”text” value=”Search…” name=”s” id=”s-head”
onfocus=
“if (this.value == ‘Search…’) {this.value = ”;}”
onblur=
“if (this.value == ”) {this.value = ‘Search…’;}” />
</form>
</div>

11) Save this file and upload it and the style.css file to your host and then check to see if it has had the desired results.

Finished Nav Bar

Variables

1) You can of course alter the text that automatically appears in the search box by editing:

<input type=”text” value=”Search…

2) This method will remove the RSS logo that come as standard in the theme, my next tutorial will deal with the nav bar and what you can do to re-instate it

show hide 10 comments

February 16, 2008 - 3:17 pm

julienne - Thanks, Guy. That will be my project for today.

February 12, 2008 - 2:04 pm
February 2, 2008 - 12:42 am

julienne - Hi Guy, thanks. I would like to put an RSS orange button and Subscribe with Feedburner just like you have at the side (except I will put mine at the bottom after my recent posts). I already created the feed and installed and activated the feedburner. I originally wanted to put the orange button back in the header close to where it used to be, but decided not since the regular live bookmark shows up in the address bar anyway.

January 27, 2008 - 8:41 pm

Guy - Julienne – where do you want the RSS Icon to appear? In the header like mine?

January 27, 2008 - 8:39 pm

Guy - Hi Julienne – glad you managed to sort the 404 on the searcj bar issue out. Let me take a look at the RSS

January 27, 2008 - 12:55 pm

julienne - Well, I’ve fixed the problem. I guess I must have entered your modifications incorrectly – since then I simply replaced your script for getting the searchform with the original <form id=”searchform” method=”get” action=”"> and it’s working again. Or it could have been a server issue that resolved while I was changing that part. I guess I’ll never know, but all’s well now.

I’m still looking forward to that tutorial on how to restore the RSS icon just in case anyone’s ever insane enough to subscribe to my blog. :)

January 27, 2008 - 12:33 pm

julienne - The above message actually should be
“The requested URL /index.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Also, another question . . . now that the RSS icon is gone, how can I make it come back? Thanks!!

January 27, 2008 - 12:18 pm

julienne - Thanks for this tutorial. I got the search form in the navbar now, but when I did the search I got an error message:

The requested URL /blog/”/index.php” was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I wonder if this is related to me making the above changes incorrectly or is caused by sth totally different. It’s been awhile since I’ve tried making a search on my own website, but I know a couple of weeks ago that was working fine. So is my prob with altering the phps or is it related to my server? Thanks!!

December 13, 2007 - 9:22 am

Guy - I’m glad you found it useful! I’m in the process of writing a few more

December 13, 2007 - 8:51 am

steamykitchen - Thanks for the tutorial! I got the search bar moved. Now on to studying your multiple column tutorial.

My site is still in test server – (sigh) this technical stuff is not for me.

Your email is never published or shared. Required fields are marked *

*

*

There was an error submitting your comment. Please try again.