It’s been about a week since my last update to this series due to me being incredibly busy with paying work, but never fear…Part 3 is here.
In Creating Your Own WordPress Theme Part 2 we finished up with a very basic theme with no styling. It works, but it’s ugly. Today we’re going to pick up right where we left off and get most of the layout, minus any graphics, done.
Open style.css so we add in some of the basics including font, font-size, h1, etc. Here’s what I’ve done so far…
body, html {
margin: 0;
padding: 0;
color: #000;
background: #fff;
font: 10pt verdana, arial, sans-serif;
}
a, a:link, a:visited, a:active {
color: #25c;
text-decoration: none;
}
a:hover {
color: #c00;
text-decoration: underline;
}
h1, h2, h3, h4, h5, h6 {
margin: 0;
padding: 0;
}
h1 {
font-size: 12pt;
}
h2, h3 {
font-size: 11pt;
}
h4, h5, h6 {
font-size: 10pt;
}
blockquote {
margin: 10px 20px;
padding: 10px;
background: #eee;
border: 1px solid #ccc;
}
.alignleft {
float: left;
margin: 0 0 10px 0;
padding: 0;
}
.alignright {
float: right;
margin: 0 0 10px 0;
padding: 0;
}
.left {
float: left;
margin: 0 10px 5px 0;
padding: 0;
}
.right {
float: right;
margin: 0 0 5px 10px;
padding: 0;
}
p {
line-height: 18px;
}
small {
font-size: 9pt;
}
Next let’s setup the page. I want the page to be centered on the screen with a fixed width of 960 pixels.
#page {
width: 960px;
margin: 0 auto;
padding: 0;
}
What this is telling the browser to do is make the width of the page 960 pixels, no margin top or bottom, center the page in the browser (that’s what auto is for), and no padding. If you’re not familiar with CSS, then use this tutorial to learn more about it. It’s what I did.
Ok, the header is a bit more complicated, although not much because I want to separate the header into two distinct sections next to each other, one for the logo, and the other for the search form. So here’s the css…
/* header */
#header {
width: 960px;
height: 80px;
margin: 0;
padding: 0;
}
#header-l {
float: left;
width: 400px;
margin: 0;
padding: 0;
}
#header-r {
float: right;
width: 560px;
margin: 0;
padding: 0;
}
#header a img {
border: none;
text-decoration: none;
}
.title {
font: 20pt bold arial, verdana, sans-serif;
margin: 15px 0 0 0;
padding: 0;
}
.description {
font: 11pt arial, verdana, sans-serif;
margin: 0 0 0 73px;
padding: 0;
}
.title a, .title a:visited, .title a:link, .title a:active, .title a:hover {
color: #000;
text-decoration: none;
}
#search {
margin: 30px 0 0 0;
padding: 0;
text-align: right;
}
#searchform #s {
width: 250px;
}
As you can see, the left side is 400 pixels wide and the right is 560 pixels. This should give us plenty of room to put a decent sized search input. Let’s change up our header.php file to reflect what we’ve done.
< div id="header" >
< div id="header-l" >
< div class="title" >< a href="< ?php bloginfo('home'); ? >" title="WordPress Mania - Crazy About WordPress" >< ?php bloginfo('name');? >< /a >< /div >
< div class="description" >< ?php bloginfo('description'); ? >< /div >
< /div >
< div id="header-r" >
< div id="search" >< ?php include(TEMPLATEPATH . '/searchform.php'); ? >< /div >
< /div >
< /div >
And the header is done. Let’s go ahead and add some navigation below the header for pages. Here’s the css:
/* Navigation */
#navbar {
display: block;
width: 960px;
margin: 0 auto;
height: 30px;
font-weight: bold;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
}
#navbar ul {
margin: 0;
padding: 0;
float: left;
}
#navbar li {
display: inline;
}
#navbar ul li.current_page_item a {
color: #000;
height: 24px;
border: 0px;
padding: 6px 10px 0 10px;
}
#navbar ul li.current_page_item a:hover {
color: #c00;
text-decoration: none;
}
#navbar a {
color: #000;
float: left;
margin: 0;
height: 24px;
padding: 6px 10px 0 10px;
}
#navbar a:hover {
color: #c00;
text-decoration: none;
}
And now add the following at the bottom of header.php
< div id="navbar" >
< ul >
< li class="< ?php if (((is_home()) && !(is_paged())) or (is_archive()) or (is_single()) or (is_paged()) or (is_search())) { ? >current_page_item< ?php } else { ? >page_item< ?php } ? >">< a href="<?php echo get_settings('home'); ?>" >Home< /a >< /li >
< ?php wp_list_pages('sort_column=menu_order&depth=1&title_li='); ? >
< /ul >
< /div >
Now to wrap up Part 3, we’re going to make two separate columns in the main body for content and sidebar and toss in the footer for good measure. So here’s the rest of the css for this lesson.
/* content */
#content {
float: left;
width: 580px;
margin: 10px 0;
padding: 0;
}
.post {
margin: 0 0 30px 0;
padding: 0 0 20px 0;
border-bottom: 1px dashed #000;
}
/* sidebar */
#sidebar {
float: right;
width: 360px;
margin: 10px 0;
padding: 0;
}
/* footer */
#footer {
clear: both;
text-align: center;
}
/* single */
.navigation {
margin: 0 0 30px 0;
padding: 0;
}
You can see we have a content area that will be on the left that is 580 pixels wide, a sidebar on the right that is 360 pixels, and the footer at the bottom that aligns the text to the center of the page.
Well, that’s it for this part, next time we’ll do more with the content area, sidebars, and if we have time, the comments. Until then…
No comments
Posted in WordPress Themes
Written on Fri, 14 March 2008 at 6:51 pm
Tags: create your own WordPress theme, themes, wordpress, WordPress Themes
If you liked this post, then consider subscribing to our full RSS feed.


Leave a Reply