Edit your WordPress theme – Headers
Some of you out there really want to start your own arcade game blog, but are clueless about web design and therefore don’t understand how to customize the look of your own WordPress website. There are plenty of tutorials out on the internet on how to make your own WordPress theme, sifting through the good ones might be a challenge. Regardless of that fact, I don’t feel the need to rewrite them because customizing your theme is a time investment no matter what you do. You need to learn HTML, CSS and understand the purpose of each html file in the theme.
However, just about any themes out there typically can look like a completely unique website by just adding your own header graphic. I am going to show you how to edit the header in your newly downloaded WordPress theme to add your own custom designed banner graphic.
What this WordPress Theme Tutorial Isn’t
I assume for you to be reading this tutorial that you have your own domain, hosting space, have downloaded and installed WordPress and know where to upload themes and then how to activate those themes. I assume you know what a WYSIWYG editor is for editing HTML pages. You have already chosen one of the available standards, either Dreamweaver, a free HTML editor, or you have chosen to use Notepad and type out everything by hand. I also assume you are not a designer, but wish you could have a nice looking site, but are too cheap to pay for your own custom design. Ok, those are the assumptions.
Now, what you need to know about WordPress themes before continuing. If you have searched the internet for the one, best tutorial on editing a theme, it probably doesn’t exist. Every theme can be a little different. So, you will still need to know HTML and CSS code to be able to look and understand generally what is going on. This information will be more for those people who don’t want to make the effort and just want to make a half baked website, change one or two things and hit the ground running.
Here’s the scenario for this theme tutorial
We need to evaluate a WordPress theme to see if it fits our needs. Now, when I first look at this theme I can kind of evaluate how the header section is built. I am going to explain this thought with the hopes that when you are evaluating the thousands of perfectly good free themes out there you can pick out how the header is made, set your criteria for you own look of you banner and then evaluate a theme based on those criteria.
What would be a sample set of Criteria?
Here are a couple of things;
- Do I want a header that is a solid color the whole width of the page, or do I want my banner to be a fixed width?
- How much space should my header take up vertically?
- Do I want my website title to be real text or a special font that I need to make into a graphic.
- Will I have a tagline under my main title?
There’s four. I know there’s more criteria you can choose, but this will have to do for now.
Choose your WordPress theme
Ok. You have your own criteria, or you are using mine above. You are visiting WordPress theme websites choosing the theme that fits the answer to your criteria. You settle on a theme, you download it, you upload it to your webspace and you are ready to edit.
I don’t know what theme you’ve chosen, but we’ll need a sample theme to use for this tutorial. I chose the theme that was reference in the original email question, a WordPress theme called ‘Thematic‘ – Real creative naming, wow. I haven’t sat down and evaluated whether this is a good theme for every purpose, cross browser compatible, if all of the front end features work, etc. etc. That is beyond the scope of this post.
When I evaluated this theme I could tell that it was probably using either a solid fill to span the width of the website in a div, or it was using a background image in the body tag to get the full width striping. What this means is I may need to use some sort of repeating background that will span smoothly the width of the screen without seams. Make a note of that for the graphics portion later. Thematic also uses real text (If I can highlight and copy the text, it is real text not an image) and a tagline. I am ok with this, I will just plan for space in my background image for that text.
Evaluation done. Let’s edit the banner already.
Not so fast, you want to rush and want an easy solution, but nothing good comes from a hack job.
First, you need to install a debugging tool in Firefox that will help you immensely understand the layout of the section of the WordPress page you are working on. Are you on Windows and hoping to be a serious developer but don’t have Firefox? Here’s your sign.
Get Firefox and then go out and download a plugin for it called Firebug. This should install itself, a drunken monkey could figure this out. Don’t restart your browser when it asks, you will want a second plugin to use for this tutorial called Measure It. Install that plugin as well. Oh, and quit this theme tutorial now if you can’t figure the automated install out.
Once Firefox is restarted with your two plugins installed, bring up your website. Now, open your HTML editor of choice, and then open your theme folder and look for a file called header.php.
Inside of this file you will see something similar to this
Again, every theme is different and classes can be called anything, but typically you will see a wrapper div and a header div. Usually you will be editing the code for the header div, and most of the time, you won’t even need to edit this file.
Second, go back into Firefox and you should see a new icon for the Firebug tool (screen).
I am not going to get into a real in depth tutorial of how to use it, but this is what you will see initially. Firebug gives you a break down of the layered html in the page as well as the classes that go with each container. When you click or hover over a div block on the left, it will highlight on the page above and bring up the associated styles on the right.
We need to find the section that I have highlighted, so in this case if you roll over the ‘branding’ div, you will see where that is on the page and the defining class. We see that this container is 940px wide, but it doesn’t give us a height. (Which is good, height is a depreciated value in xhtml and shouldn’t be used when possible. Use margin and padding instead for the same purpose)
We need to find the height to know for our graphic. Oh, and note – Firebug tells us where the class is located in what file. In this case it is a file called ‘2c-r-fixed.css‘ and you can find this class on line 9. We’ll need that information later.
You should now also see a little icon that looks like this loaded into the lower left corner.
This is the ‘Measure It’ tool that allows you to measure pixels dimensions on screen. Click the icon once, everything should grey out, and then draw in your browser window. When done, click the icon again to turn the tool off.
What we want to do is measure the height of the area for the graphic. The blue at the top in the screenshot is the Measure It tool at work. As always, click the image for a larger view.
This is the approximate area we may want to make our static banner, or the part that doesn’t repeat. I measured about 244px, you measurements may vary a little but not much.
Editing the WordPress Theme CSS files?
Now, look inside a folder called library for a folder called layouts. In there you will find the ‘2c-r-fixed.css’ file. Look for your ‘branding’ class. This is where we will code in by hand your new background image that is going to be 940px x 244px. You will need to make one of your own, or you can download mine. I just used a generic graphic from the Juice Drops library (available for purchase online) to make my background. Here is that image, right click the image and save the actual 940px x 244px size.
I added some dark fading gradients so we wouldn’t see the edges of the graphic and therefore, not to have to worry about it repeating. (I had to change the background color in the header class to #0D181E to get the color to fade smooth)
Note: Before I tell you to edit the CSS file, one word of caution here. When evaluating themes you will probably figure out that some themes will never be updated, and some will. Some theme authors feel passionately about their themes to constantly add to them with new features, new variations on colors, etc. etc.
I am writing this tutorial with the assumption that you will customize the theme long term to your use and never update the original core files. If you feel like you don’t know much at all about WordPress theme editing and you might update this theme at a later point then you will want to research how to make an additional stylesheet file and update the linking to that file when you update the theme so you don’t lose your styling changes. These concepts are also out of the scope of this article.
End of public service announcement.
Ok, you’ve got your sized graphic, now let’s add a rule to the class. Anywhere between your {} brackets, type in this (Change the image path to your liking and where you put your image. I put mine in the theme images folder so my path goes up two directories);
background:url(../../images/header.jpg) no-repeat;
And this is how the result looks;
There, you’ve changed a background graphic in a WordPress theme
The original question that I had to my website did not ask how to change the header graphic. However, I have given some great advice on developing your own WordPress theme in this tutorial whether you realized it or not.
To review, those tips were;
- How to evaluate a theme from a background construction to fit your needs and skills
- Plugins to use in Firefox that make development for WordPress themes that much easier
- Using the existing classes to modify look without modifying dimensions of an HTML layout
Again, there isn’t an easy way to make your theme work for you. I can’t count how many hours I have spent on my arcade game theme for my WordPress blog, but I also am very proud of my work.
Roll up your sleeves, make good decisions, and learn well formatted and structured HTML. Trust me, it’s a worthwhile skill in any business to have on your resume, so spend the time. You might try out the CSS books from Sitepoint, those are some excellent tools that are written like the ‘For Dummies’ series explaning very simply in average person – non technical terms how some of this stuff works. Spend $30, save hours and hours of time, and maybe you can give back to the community in a month when you become and expert yourself.
Related Useful WordPress Tutorial Links
In the beginning were you lost because you weren’t familiar with the concepts suggested to know? Well, here are some other good explanation tutorials. They aren’t completely beginner level tutorials, but they are still good.
Explaining the hierarchy of a WordPress theme and the necessary pages
http://www.killersites.com/blog/2008/creating-wordpress-themes-from-scratch/
Here are some similar arcade posts
- Custom Super Bug WordPress Theme
- Donkey Kong WordPress Theme – Ver. 1
- Wrap text around your arcade images
- Arcade Game Inspired WordPress Theme – BCPArcade.com
- Atari Command Free WordPress Theme
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.
Comments
I ended up adding some javascript code to my header to rotate the image each time a page was loaded. It worked out great. Jeff was really helpful in helping me set up my blog! If you want the code I used, let me know.
@Jeff Waldron:
Kind of an interesting comment…
This WordPress tutorial is more about how you can change the header of most any free WordPress theme and have a website that kind of looks like ‘your own’.
But, if you want to take it the next step and make your banners rotate (which you probably won’t be able to use this technique in this tutorial because it’s a background image) you can use a now available WordPress plugin to rotate your banners called ‘Header Image Rotator‘.
Wow! Thanks Jeff. I will definitely put this info to use. You’ve been busy writing, I was reading your 15 most valuable post when I got your email. Nice work on both.
I like the firebug plugin a lot!
Thanks for your help,
Paul
@Paul Olson:
No problem. I find learning about even the smallest little tools or plugins can change a designer’s life. Like this weekend, at the Blog Indiana conference I learned about setting up users on accounts in Google Analytics and that has been a huge bonus for me.
Please shoot back info when you try things out if you have very specific questions so everyone can benefit from your beginner experience to custom WordPress themes.
Hello,
I’ve followed your WordPress header tutorial … but maybe Ive missed something because my header doesn’t change.
Here’s the site: http://www.googlephonerumors.com.
Here’s the edited CSS:
#branding {
width:940px;
margin:0 auto;
background:url(../../images/gpr_header.jpg) no-repeat;
}
Any ideas?
Thanks.
Philip
@Philip B.:
The best guess I have with what you sent me is that the image path isn’t right. According to what you have, that image path would be looking for a directory of ‘images’ inside of wp-content. I doubt that is right, but it is hard to know without knowing your directory structure.
I almost always use absolute paths. You might try that, it take a little thinking out of how many ../ up directories you need to use.
May I ask you?
How to add the logo in the wordpress?
Is that need go to Page Template or header script change the script? May I know how to solve it? Thank you!
Not sure what you are asking….
Are you asking about how to add a logo instead of a wide banner? Or are you asking how to add it from the WordPress admin interface?
Thanks Jeff,
Very clear, very useful. You’ve obviously spent a lot of time giving something to us for free. Can’t believe I was the first to give you a Stumble ‘thumbs up’.
@David,
Thanks for the note. Did you use the tutorial on a site you developed that you wanted to show off?
hello guys
i have some problems , i got last ver for WP , i want some ways to change the themes to using games how to that ?
I make few modifications to the code when it comes to the header. I use instead this very flexible online WP theme editor called Lubith that has a great interface and allows me to select any element of the layout and drag it around/ resize it/ add/remove images or bkg. color, set opacity, borders, round corners, I can even remove the site’s sitle, description and menu from the design in order to make the header stand out.
Sorry, the comment form is closed at this time.
August 14, 2008
WordPress is weblog creation and publication software, those intimate diaries that are the rave on the Internet. Website Hosting