Create a Theme #4 (final)

Once the main page is looking the way we want, the next step is to click links around the site – pages, archives, single posts, etc – to see how the rest looks. Doing this here, we immediately see a problem: the page and post headers really don’t look right on the sub-pages. The image on the left shows the main page as it is currently. The one on the right shows a sub-page.

CHANGE

.arc h2 {
	}
	
TO
	
.arc h2 {
	font-size: 1.3em;
	padding-bottom: 20px;
	}	

The first change is another stylesheet modification to increase the size of the (archive) page title and create some space under it. But after that, we are going to have to modify some HTML. The files we have to look at appear in Themes –> Presentation as Archives and Page Template.

<h2><?php the_date() ?></h2>

In both files we are looking to delete the code shown above. Since I created these “blank” templates, obviously I planted that line just to provide an example of how easy it is to identify and remove or change a theme’s underlying code. Adding new code is just as easy.

<h3 id="post-<?php the_ID(); ?>">

In both files, right under where we do that deletion, is the above h3 code. This what controls the presently somewhat small article title and we need to change it as follows.

CHANGE

.entry h3 {
	}
	
TO

.entry h3 {
	font-size: 1.8em;
	}

And although obviously there are lots of minor tweaks we could do, we have gone pretty smoothly I think from a blank theme to a ready site. The key to developing a WordPress theme is to take it a step at a time and check the result as you go. Sooner or later you will run into the dreaded cross-browser inconsistencies and they might get you pulling your hair out. But most of the time a methodical, step-by-step approach is all it takes to produce something very respectable.

Create a Theme #3

By the end of the last article we had a page which was beginning to look more like it could belong on a real site: a title graphic and some basic colors, set into a centered block and split into two columns. If you did your homework, adding a couple of with-pictures posts, you should now have something looking a bit like this:

There are more ways to fancy up your picture displays than I am going to illustrate here, but for this exercise, all you need for your posts is code along these lines. Note that if you want the text to wrap around the pic(s) then you should not put a carriage return before the text:

<img src="http://yourdomain.com/path_to/yourpic.jpg" width="500" height="250" alt="" />
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <a href="http://refer.ccbill.com/cgi-bin/clicks.cgi?CA=925452-0000&PA=1116973">Persephone from Crazy Babe</a>

We are going to shoot through a lot of formatting today and since most of it is straightforward, I shall just show the way blocks of your stylesheet should look after they are done, commenting when something needs saying. But before we get on, I want to plant a thought in your head, which is that thus far we haven’t touched a line of HTML and as far as I can tell there are about two-dozen people working along with this. That’s twenty-some different designs from the same HTML. Makes you think doesn’t it: maybe this CSS stuff has potential?

If you are in any doubt about the impact of these changes, refer to the source code of your blog’s main page and make such changes one item at a time, so that you can see the result and more easily adapt my settings for the design you are creating.

/*
Theme Name: Stripped
Theme URI: http://carpejugular.com/
Description: A stripped WordPress 2-column theme to act as a foundation for individual designs.
Version: 1.0
Author: John Foulds
Author URI: http://carpejugular.com/
*/

/* globals */

body, html, p, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, blockquote, fieldset, input { margin: 0px; padding: 0px; }
:link, :visited { text-decoration: none; }
ul, ol { list-style: none; }
h1, h2, h3, h4, h5, h6, pre, code { font-size: 1em; }
a img, :link img, :visited img { border:none; }

body {
	background: #000;
	text-align: center;
	font: 80%/1.7em "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Verdana, Geneva, sans-serif;
	color: #BFD8F1;
	}

h1, h2, h3 {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-weight: normal;
	}

h1 {
	}

h2 {
	}
	
h3 {
	}

p {
	}

a {
	color: #95BEE7;
	}
	
a:hover {
	color: #E29634;
	}

img {
	border: none;
	}

input[type=submit] {
	background: #BFD8F1;
	padding: 2px 4px;
	border: 1px solid #082B6B;
	color: #082B6B;
	cursor: pointer;
	}

/* wrapper */

#wrap {
	text-align: left;
	width: 90%;
	margin: 0px auto;
	min-width: 770px;
	}	
	
/* header and main body */

#header {
	background: url(images/logo.jpg) top left no-repeat;
	height: 200px;
	margin-bottom: 50px; /* NEW */
	}

#header h1 {
	text-align: right; /* NEW */
	font-size: 1.5em; /* NEW */
	}
	
#header h2 {
	text-align: right; /* NEW */
	font-size: 1.3em; /* NEW */
	}
	
#content {
	float: left;
	width: 70%; /* CHANGED */
	}

#content p {
	}
	
.entry {
	}
	
.entry h2 {
	font-size: 1.8em; /* NEW */
	}
	
.entry h3 {
	}
	
.entrymeta {
	font-size: 0.85em; /* NEW */
	}

.entrybody p {
	}	

.entrybody ul {
	}

.entrybody ul li {
	}
		
.entrybody ol {
	}
	
.entrybody ol li {
	}
	
 /* NEW */
.entrybody a {
	color: #95BEE7;
	padding-bottom: 2px;
	border-bottom: 1px dashed #95BEE7;
	}
	
 /* NEW */
.entrybody a:hover {
	color: #E29634;
	padding-bottom: 2px;
	border-bottom: 1px dashed #E29634;
	}
	
.entrybody img {
	padding: 7px; /* NEW */
	border: 3px double #082B6B; /* NEW */
	margin: 5px 10px 5px 0px; /* NEW */
	}

blockquote {
	}

p.comments_link {
	margin-top: 10px; /* NEW */
	font-size: 0.85em; /* NEW */
	}	


/* archives */

.arc {
	}
	
.arc h2 {
	}	

/* comments */
	
.nocomments{
	font-size: 0.85em; /* NEW */
	}

.commentblock {
	margin-top: 5px; /* NEW */
	padding: 0px 0px 50px 20px; /* NEW */
	}
	
.commentblock h2 {
	padding-top: 30px; /* NEW */
	font-size: 1.5em; /* NEW */
	}

.commentblock p {
	}
	
.commentblock ol {
	}

li.alt {
	}
	
li.standard {
	}
	
.commentauthor {
	}

.commentinfo{
	font-size: 0.85em; /* NEW */
	}

.commenttext-admin {
	}

.commenttext {
	margin: 10px; /* NEW */
	background: url(images/quote.gif) no-repeat; /* NEW */
	padding: 0px 0px 30px 40px; /* NEW */
	}

h2.commentsformheader{
	}

.commentsform {
	}

.commentsform form {
	}

.commentsform p {
	}

.commentsform form textarea {
	}


/* sidebar */

#sidebar {
	float: right;
	width: 23%;
	font-size: 0.85em; /* NEW */
	}

#sidebar p {
	}
	
#sidebar ul {
	}
	
#sidebar ul li {
	}

#sidebar h2 {
	padding-top: 30px; /* NEW */
	font-size: 1.5em; /* NEW */
	}

#sidebar ul a {
	}
	
#sidebar ul a:hover {
	}

#sidebar ul li ul li {
	background: url(images/arrow.gif) left center no-repeat; /* NEW */
	padding-left: 15px; /* NEW */
	} 


/* search */

#searchdiv {
	}
	
#searchdiv p {
	font-family: Georgia, "Times New Roman", Times, serif; /* NEW */
	font-size: 1.5em; /* NEW */
	}
	

/* footer */	

#footer {
	clear: both; /* NEW */
	padding: 50px 0px; /* NEW */
	text-align: center; /* NEW */
	}
	
#footer p {
	}

A word about h1 and h2 in the header. In real life you would choose a site title and description which was more imaginative than I have done here: perhaps a title with two key phrases in it and a description repeating them and adding three more. Although the description in particular should read normally, IMO they cannot help but be a slight distraction for your visitors. So until a few months ago I would have hidden them via display: none or with a text-indent to shove them away to the left of the visible screen. But I have been reading that Google has now got wise to these tricks and doesn’t like them, which is why these headers are tucked away (fairly) discreetly at the top of the screen.

Otherwise worth noting is a personal choice to use the bottom border (with a couple of pixels padding) in place of regular underline for some links. I prefer this approach because it does not cut through the bottom of downward extending letters and it adds a slightly less common touch to sites making the links stand out better while still using the convention with which surfers are familiar.

I decided there wasn’t sufficient gap between the columns, so I cut the left column width back to 70%. Take a look at the style for the footer and notice it includes clear: both. It mean clear both margins and it needs to appear in any block which follows a multi-column block, otherwise browsers will try to tuck the new div into any spaces between them or onto the end of the shortest column above.

The quote marks used next to comments is a 30-pixel square gif and the arrow used in the sidebar an 8×9 gif which I made and uploaded to my theme image directory. Look at the unusual format of input[type=submit]: that is called an attribute selector and does away with the need (unless we have another reason for using one) of having to give each submit button a class. We are also able to add a cursor to this button with the cursor: pointer attribute.

And that is all the detail we shall worry about on the front page at the moment. In the next article we shall go through the other pages to check whether there are any anomalies or any additional styling with which we need be concerned.

If you want to check what my version of the design looks like after all the stylesheet changes have been made in this article, click here.

Create a Theme #2

We finished the first article with a background color and a header. However, thus far the results are less than impressive, so we shall begin today by getting some shape into our pages and making the content visible.

To begin that, we need to determine a width for our pages and these days it is important to remember that while around 80% of surfers use 1024×768 or more, a very sizeable minority browse at lower resolutions. In my view, the best solution for sites which are wholely or mainly text, is a completely fluid design which will adapt to any size of screen. This isn’t just a matter of aesthetics: non-IE6 surfers (even they in some circumstances) can change the size of the displayed fonts and totally mess up static designs. The decision needs to be weighed against the possibility that single-line text elements can end up stranded next to an excess of white space on very big screens.

As I have illustrated in an earlier article here, there is nothing to prevent image sizes being allowed to change too. However very high quality images and some careful maths are needed to make that work. What we shall do here is a compromise: express the width of our working area as a percentage of the screen, but – because we don’t want a design we know must accommodate quite a lot of images – to degrade at low resolutions, we shall limit how small that area can become. Two parts of the stylesheet need our attention. First we add text-align: center; to the body block.

/* globals */

body {
	margin: 0px;
	padding: 0px;
	background: #000;
	}
	
	
CHANGE TO:

/* globals */

body {
	margin: 0px;
	padding: 0px;
	background: #000;
	text-align: center;
	}

This is to cater for IE6, which will not handle auto margins (see later) correctly otherwise. Next, if you take a quick look at header.php in your WordPress Dashboard theme editor, you will see that the single division containing all the sites content has been defined as div id=”wrap”.

<body>
<div id="wrap">	
	<div id="header">	
		<h1><a href="<?php bloginfo('siteurl'); ?>"><?php  bloginfo('name'); ?></a></h1>
		<h2><?php bloginfo('description'); ?></h2> 
	</div>

Therefore back in our stylesheet we need to add some parameters:

/* wrapper */

#wrap {
	}	

	
CHANGE TO:
	
/* wrapper */

#wrap {
	text-align: left;
	width: 90%;
	margin: 0px auto;
	min-width: 770px;
	}	

The text-align addition is to restore the default behavior that we messed up a few minutes ago and we have opted for the width to be 90% of the available screen, except that it cannot be narrower than 770 pixels wide. When you want something to be centered and a margin is involved, you set both margins to be calculated automatically. margin: 0px auto is shorthand for top=0, right=automatic, bottom=0 and left=automatic. If all four margins were to be the same, we could enter the dimension only once and when left and right/top and bottom are the same, we only have to state the two dimensions involved. It is not currently necessary to put a dimension measure with a zero, but that seems set to change, so it’s a good idea to get into the habit now.

All very easy, except that there is a small snag: namely that IE6 doesn’t recognize the min-width instruction. Conditional comments to the rescue! Once you have saved your latest version of the stylesheet, open up header.php:

FIND THIS LINE:

<<style type="text/css" media="screen">@import url( <<?php bloginfo('stylesheet_url'); ?> );<</style>


AND ADD THIS UNDERNEATH:

<<!--[if lte IE 6]>
<<link rel="stylesheet" href="<<?php bloginfo('stylesheet_directory'); ?>/ie6.css" type="text/css" />
<<![endif]-->


CREATE A NEW FILE AND PUT THIS IN IT:
#wrap {
	width: expression(document.body.clientWidth < 800? "770px": "90%" );
	}

If you want to dig more deeply into the options by which browsers can be identified take a look here. The variation I am using says "If the browser is Internet Explorer version 6 or less", read in a second stylesheet called ie6.css. In this instance, because IE6 will ignore the min-width command which it does not understand, and since this bit of jiggery pokery was read in second, this width command will replace the one in our main stylesheet.

Once you have created ie6.css on your PC, FTP it to your theme directory and CHMOD 666 for future editing.

This is of course a bit of hackery, something to avoid unless there is no choice, but the use of conditional comments (which must appear within HTML and not in CSS) means that our pages will still validate fully and also that we are doing no more than making use of the rules of precedence built into the concept of CSS.

Fonts

Now let's introduce some color to try to make this all readable. When I added the name of the site to the background graphic, I did so with a gradient reaching for #BFD8F1 to #082B6B. I'm going to start by using the lighter of those two colors for the text and a variation a couple of shades darker - #95BEE7 - for the links. We also need a hover color and for that I have chosen an orange: #E29634.

The result makes a reasonable starting point and this is how you get there. In your stylesheet:

/* globals */

body {
	margin: 0px;
	padding: 0px;
	background: #000;
	text-align: center;
	}

	
CHANGE TO:

/* globals */

body {
	margin: 0px;
	padding: 0px;
	background: #000;
	text-align: center;
	color: #BFD8F1;
	}
	

AND
	
a {
	}

a:hover {
	}
	
	
CHANGE TO:

a {
	color: #95BEE7;
	}
	
a:hover {
	color: #E29634;
	}

If I can use blue or something with blue in it for links, that will be my first choice. Similarly something red or red-related for the hover. That is because surfers are tuned in to the idea that links should be colored blue, turning red on hover, so providing that doesn't contradict where my colors are going, I want to accommodate that preconception. In this instance, since an orange picked up from the woman's leg led me to the blue, there is no conflict at all.

We need to do something about the font next and although there are ways to deliver fonts to someone who does not have what they need for your site, these introduce delays and possibly set off firewall alarms. Which means we are stuck with the very small number of fonts that all versions of Windows and Mac PC's can read. Once more we are in the realms of personal taste as well as the needs of a particular design, but I'm going to start with Lucida (similar to Verdana and readable at small sizes) for the regular text and Georgia (Times Roman with a little more style) for headlines. I think large fonts in bold are usually ugly, so I have also instructed font-weight: normal; for the headers. But like all the specifics that I am suggesting you can put in whatever suits your tastes and the design you are developing.

/* globals */

body {
	margin: 0px;
	padding: 0px;
	background: #000;
	text-align: center;
	color: #BFD8F1;
	}

h1, h2, h3 {
	}

	
CHANGE TO:

/* globals */

body {
	margin: 0px;
	padding: 0px;
	background: #000;
	text-align: center;
	font: 80%/1.7em "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Verdana, Geneva, sans-serif;
	color: #BFD8F1;
	}

h1, h2, h3 {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-weight: normal;
	}

Three things to note above. The first is that in addition to the fonts I expect most visitors will have installed, I have offered Windows, Mac and fallback font in case they do not. That way, even those people will see something near what I intended, rather than viewing the site in whatever their default font happens to be. Secondly, I do not believe in messing with a surfer's preferences more than necessary, so instead of setting a specific font size in points or pixels, I have elected for a percentage (80%). I keep the browser in which I check my designs on totally default settings and I use the most popular resolution, so that I see my designs the way that the largest single group of visitors will. 80% looks a little large at the moment, but it will do. Similarly I have chosen a line height (that 1.7em, which means 1.7 times the height of the letter M at the chosen font size) which may need changing later.

Columns

The last thing we shall do today is get the columns sorted out and if you open up the Main Index Template you will see at the top that the main body of our pages is wrapped within div id="content". Next open the Sidebar file and you will similarly see that all the links and whatnot in the narrow column are wrapped into div id="sidebar".

Since this is a semi-flexible design and it is more likely to adapt well to different sizes if our dimensions are based on the smallest width allowed (770 pixels), the column widths must be expressed in percentages. I have opted for 560 pixels (560/770=0.73) for the main column and 180 pixels (180/770=0.23): ie 73% and 23% with the leftover 4% to act as a margin between the two.

#content {
	}
	
	
CHANGE TO:

#content {
	float: left;
	width: 73%;
	}

	
#sidebar {
	}
	
	
CHANGE TO:
#sidebar {
	float: right;
	width: 23%;
	}

Out out damn formatting!

Actually I lied, we are going to do one more thing today. If you look at where we are now, the default WordPress entries have obligingly placed themselves into two columns, but there is spacing all over the place which we have not put there. We also have underlined links (whether we want them or not) and symbols ahead of our listed links. All of this built-in formatting would not be so bad if it were rendered consistently by the various browsers. But it is not. Explorer, Firefox, Opera and all, each have their particular quirks.

/* globals */

body {
	margin: 0px;
	padding: 0px;
	background: #000;
	text-align: center;
	font: 80%/1.7em "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Verdana, Geneva, sans-serif;
	color: #BFD8F1;
	}
	

CHANGE TO:

/* reset formatting */

body, html, p, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, blockquote, fieldset, input { margin: 0px; padding: 0px; }
:link, :visited { text-decoration: none; }
ul, ol { list-style: none; }
h1, h2, h3, h4, h5, h6, pre, code { font-size: 1em; }
a img, :link img, :visited img { border: none; }


/* globals */

body {
	background: #000;
	text-align: center;
	font: 80%/1.7em "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Verdana, Geneva, sans-serif;
	color: #BFD8F1;
	}

The best way of dealing with this is to undo all this formatting and then set your own, block by block, item by item, as you develop your design. I strongly recommend that you add the reset formatting block to every stylesheet with which you work.

Homework

WordPress very obligingly provides some default data so that we can immediately see what a theme will look like. However it does not include any entries which involve pictures and obviously these will be an essential part of our babelog. So during the next couple of days, as well as updating your version of this design, create a couple of posts.

One should include a single image 500x250 pixels and the other two pictures 200 pixels square. Just create the two posts, putting into them the usual (HTML) links to the pics (img src= etc), immediately followed by a half-dozen lines of blurb. There is no need for any formatting, paragraphs or line breaks. Just paste in the correct links to the images that you would use in a regular HTML page and type in the text. The output will look weird: that is what we shall fix in the next article.

Create a Theme #1

Let’s begin with a roadmap of where this series is going, so that you can see if it will interest you.

We are setting out with a basic WordPress theme which has been “stripped”. In other words, we have a no-frills set of HTML files – Archives, Comments, Footer, Header, Main Index Template, Page Template, Search Results, Sidebar – and a stylesheet from which almost all the settings have been removed:

body {
	margin: 0px;
	padding: 0px;
	}

h1, h2, h3 {
	}

h1 {
	}

h2 {
	}
	
h3 {
	}

p {
	}
	
...etc

The theme is actually usable in its current state and shows you what any visitors will see who are using browsers which cannot handle stylesheets:

unstyled blog theme

In the above graphic you are also seeing the entries which WordPress includes in their default install. I have left them untouched, so that if you want to set up a test blog and work along with this series, everything on your site can look just as it does here. That should make the series easier to follow.

This will not be just a classroom-style exercise. During this series we are going to turn this raw theme into a complete, fully-working theme which you could use on a site. I shall explain what I am doing in a way which will allow you to change things to suit your own tastes and needs. There will be 1-2 articles per week, so you will have time to make your personal modifications between articles and ask questions if you get stuck. I have opened a thread in the forum – HERE – for any questions arising from these articles. I only request that you do not jump ahead of where we are, because that will make the thread hard for others to follow. If you have general questions about WordPress or CSS, start your own thread!

We are going to be building a 2-column theme with a black background, but you will be able to change that for any color scheme you want. It will be coded as table-free XHTML 1.0 Strict: the HTML, CSS and RSS feeds will validate. I am going to be making the theme up as we go along, so that you can follow not only the technical aspects of the process, but also what passes for the creative thinking behind it. I want to stress that what I explain here is by no means the only way to tackle this job. It’s just the way that I do it and when you become more experienced you will surely develop your own approach. Here is what you will need to work along:

  • A working test installation of WordPress. Everyone who runs blogs should have an installation which is not promoted publicly, so that they can build and test new designs. It can be in a sub-directory of an existing site and use an existing database (providing you use a different table prefix: see below). All that matters is that you have such an installation.
  • An installed copy of the stripped theme which you can download from here and install it on your test site (see below).
  • Optionally an HTML editor and a graphics editor.

Installing WordPress

WordPress is one of the easiest installs around. Download the current version from here, then follow the Famous 5-Minute Install. For the purpose of creating a test installation I recommend you do install in a sub-directory (as explained in step 5) and if this install is going to share a database with another WordPress install, make sure that when you edit wp-config-sample.php (step 3) you change the default wp_ table prefix:

$table_prefix  = 'test_';   // Only numbers, letters, and underscores please!

Installing the “Stripped” theme

Download the zip file from here and extract it onto your PC using directory names such that a sub-directory called “stripped” is created in your themes directory:

FTP the stripped directory to the parallel location on your server and change the permissions of the css file and php files to CHMOD 666 so that they are writable.

Colors

Every design has to start somewhere and for me it begins with thinking about colors. There is nothing to prevent you using any color you like but I think most of us would agree that certain colors tend to suggest particular niches: for example teen sites often use pinks and pale blues, babe and mature sites are frequently purple, ebony sites brown and orange, etc. There is no percentage in confusing our visitors, quite the contrary, it pays to use their preconceptions to our advantage. So in this instance (this is a hypothetical exercise for me) I imagined I was tasked with designing a blog for a leg-fetish site and therefore decided on a black background. Dark colors tend to suggest fetish or hardcore to porn surfers and black stockings are considered sexy by many, so it was a logical if uninspired first step.

If one of my designs is to have any graphics at all, the next thing I do is hunt around for an image which I can use to reinforce the impression the background color is intended to convey. As you will see in a moment, for this design I decided on a picture of a woman wearing fishnet pantyhose and extreme stiletto heels. I jacked up the contrast and saturation to create some additional impact, faded it out to black and then cropped. This is (a reduced-size version of) the result:

Logo

Okay, so we have a black background and a header image, now for the rest of the colors. The two elements we have chosen so far do enough to suggest what we are offering as soon as someone reaches our site. So next I try to find highlight colors that will give the site some individuality. There is no way to find something no-one else has ever done, but I want to avoid the most common combinations, which in this case means reds and golds. I don’t like to simply pull colors out of thin air and anyway I’m not great at guessing colors, so I use a handy program called Color Schemer. It has an eye dropper tool I can hover over my header image (in this case picking up some of the oranges and browns from the woman’s legs) and it will show me related colors. I found a blue which looked promising and decided it would be good basis for highlighting this design.

That is twice I have used the word “highlighting”. Blocks of text we want our visitors to read and above all, links, should contrast strongly with the background. That consideration doesn’t commit us solely to black on white or white on black, but it imposes severe restraints. We can relieve what could easily become very boring color schemes with highlights: that is what the blue will do in this instance and to kick off I found two tones around my starting point – #BFD8F1 and #082B6B – which thus far at least work, for me.

Header

We are already partway, but I want to add the site title. It should be displayed, but I want to keep the h1 and h2 headers free for keywords to help with the search engines, so I usually include the site name in the header/background graphic. I tend to go towards slightly understated, because I want surfers to spot the site name. I do not however want it to have so much impact their eyes don’t move on. Once my graphic is done and optimized, I upload it to the images directory of my theme folder

Putting it together

Go to your WordPress “Dashboard” and select Presentation » Themes. The Stripped theme should appear in the list below. Click on it to make it the current theme. Next click on Theme Editor which should open a page with style.css showing.

You can edit this file directly, but I don’t like working with a small window, it doesn’t allow tabbing, etc., so my choice is to copy and paste back and forth between the WordPress editor and my usual HTML editor.

I also know that at some point I shall always bollox something up, so although I have a pristine copy of the theme on my PC, I don’t really want to have to start completely over when that happens. Therefore I create a working directory somewhere on my PC and after each set of changes I save each file that I work on to it: but only after I have visually confirmed that the latest changes work!

We shall be digging into the HTML soon enough, so for now take my word for it that at this point we need only be concerned with the body and #header parameters:

FIND:

/* globals */

body {
	margin: 0px;
	padding: 0px;
	}

CHANGE TO:

body {
	margin: 0px;
	padding: 0px;
	background: #000;
	}

FIND:

/* header and main body */

#header {
	}
	
CHANGE TO:
/* header and main body */

#header {
	background: url(images/logo.jpg) top left no-repeat;
	height: 200px;
	}

Those who are used to writing #000000 to represent black in HTML, may wonder what happened to three of the zeroes. The answer is that CSS allows you to represent identical pairs of color identifiers with just one letter/number and since part of the value of CSS is to be able to reduce the amount of code we use, it makes sense to take advantage of this facility.

Note that when providing the path for any images we want to use, we can provide full url’s, absolute url’s (prefixed with an oblique and then the full path from our root directory), or most easily, as I did here, simply reference the image directory relative to the directory in which the stylesheet is stored. Note also that you never put quotes around url’s when using them in stylesheets.

The default positioning for background images is top-left, so since that is what I want in this instance, I do not need to be specific. However I have been, because if I come back to this file in a year, I shall be reminded instantly how this image is placed. I must add no-repeat, since repeat is the default and that is not the behavior I want here. Finally I have set the height of the header div to match my graphic and ensure that it is all shown.

Homework

Which is enough to read for one day and – if you want to be creating a site to use yourself – you need to think about your own color scheme and prepare some graphics, before we go much further.

Your header image can be as simple or as complex as you want, but remember it has to be loaded and although we want to impress people, we do not want them to get fixated by it. You can choose any height you like, but I would recommend sticking under 250 pixels so that header is not all anyone sees when they load your page. Stick within 770 pixels wide (although our pages will stretch wider than that) and when finished, call your header image logo.jpg and upload it to the images directory of the Stripped theme.

Useful links

Never steal images, not even part images. If you don’t own anything suitable for your header, find a picture among the content that sponsors make available for affiliates, contact the sponsor in question, explain what you want to do and offer a credit on your page. I have done that frequently and to date, no-one has ever said no.

Create a WordPress Theme

There are literally hundreds of WordPress themes available for free, many of them excellent designs. However, a serious commercial website needs to be unique and a simple change of header image doesn’t really qualify.

People like myself, who run tutorial sites and tell you that modifying a WordPress theme is easy, well let’s just say we are only being partly honest. The principles are straightforward enough and it isn’t too hard to make some sense of all the code. But when you look under the hood of WordPress and spend a little time digging around, it soon becomes obvious that it is every bit as complex as it first appeared. Just not in the ways you initially thought.

Part of that complexity comes when you gain some understanding of how it all works and the almost infinite range of possibilities becomes more clear to you. Sure you can create a one-column or a two-column design, but there is nothing to prevent you having 3 or 4 columns, no reason why the sidebar needs to be on the side. And just because the links follow the search box in the default design, doesn’t mean it has to in yours.

One of the best ways of coming to grips with WordPress is not by making minor tweaks to existing themes, but by building your own design from scratch. Not entirely from scratch, because the most efficient way I have found to build themes is to start with a stripped-down theme. Check that link out and what you will see is a basic WordPress layout, complete, but with absolutely no styling. It has a stylesheet and that stylesheet has in it identifiers for all the ID and class tags used in the HTML. But they have no parameters. Yet.

Over the next few articles, we are going to turn that skeleton into a full-blown, working theme. “We” because I have zipped up the blank theme so that you can download it, unzip it and then load it into the themes directory on your own test site. Test site? Even if you are an old hand with WordPress, it makes sense to have a second installation in a sub-directory so that you can test themes and plugins ahead of making them live on your main site. And this exercise will be spread over several articles with a day or two between each, so it really isn’t going to be practical to work with a site which already has visitors.

Here is the zip file and you have a couple of days to set it up and think about whether you simply want to go along with the theme I shall create, or do one of your own. I’m going to go step by step through the whole process from beginning to end, so with a minimal knowledge of HTML and CSS, you should have no trouble following. And if any problems do arise, just post them on the board here and we shall work them out.

I’m going to create a fairly typical “babelog”, one which combines text and pictures: we may even add some RSS feeds from a couple of sponsors. I’m not into the “Hello World” type of exercises you get in text books: when this is done it will be a fully working site. So if you want to go along for the ride, download the zip file now and check back in a day or two for the first article.

Deep Purple Theme

3-column and 2-column versions

Deep Purple 3-column themeDeep Purple 2-column theme

“Deep Purple” is an attempt to move away a little from traditional blog layout while retaining its functionality. It is also a flexible design which automatically adjusts to the visitors’ screen resolutions, but restrained between 770 pixels and 900 pixels so that it never squashes or stretches to the point of being spoiled. Sections in the sidebar(s) can easily be renamed, commented out, changed and moved around. It is a simple matter to incorporate banner display software, top lists, etc.

Order Form

Please state theme required and payment preference (ePassporte or PayPal)

Verify

These are complete WordPress themes and include a full set of all the key templates. Created entirely in validated XHTML/CSS, they are table-free for maximum search-engine friendliness and ease of modification and maintenance.

Delivered as zip files, these themes are ready for use: just upload to your server and go! They will work with all versions of WordPress 1.5+ and require no plugins or other modifications.

There are no usage limitations on these themes except that they may not be re-sold unless as part of a complete site, nor may they be claimed as the buyer’s original work.

Black Red Theme

3-column and 2-column versions

Black Red 3-column themeBlack Red 2-column theme

“Black Red” is an atmospheric theme ideal for several kinds of sites, especially for those with a fetish flavor. It is a fixed-width design available in 3-column and 2-column versions. Although a text-based header is recommended for search-engine appeal, it is simple to use a graphic header. The sidebars are easily modified and plugins as well as the output from standalone scripts such as banner rotators can be added without difficulty. The design uses no tables and is valid XHTML strict.

Order Form

Please state theme required and payment preference (ePassporte or PayPal)

Verify

These are complete WordPress themes and include a full set of all the key templates. Created entirely in validated XHTML/CSS, they are table-free for maximum search-engine friendliness and ease of modification and maintenance.

Delivered as zip files, these themes are ready for use: just upload to your server and go! They will work with all versions of WordPress 1.5+ and require no plugins or other modifications.

There are no usage limitations on these themes except that they may not be re-sold unless as part of a complete site, nor may they be claimed as the buyer’s original work.

Site Usability

We all know that WWW stands for world wide web, but what exactly should that mean to webmasters? One thing it means is that almost every surfer who visits your site will have seen hundreds of other sites first. They therefore arrive with expectations based on those previous experiences, not only in content terms and whether you site is easy on the eye, but also about that geeky-sounding thing: site usability. And right away I confess that this is going to be a case of do as I say, and not as I do.

We are all aware that this is important stuff, but at most we usually think only about whether our join links stand out enough. There are many more factors to consider and you could be costing yourself a lot of money if you ignore them. Study after study shows that surfers quickly become “trained” by the layouts they encounter most often. That reality, together with common perceptions of how the internet should be utilized, means that if you offer something different, visitors to your site will not be at ease. That is not what you want, when you are trying to sell them something.

Where is it?

Surfers expect to see certain features on the sites they visit and they expect them to be in specific locations. If you offer these features but place them “wrongly” you might be dismayed just how few people see them at all and downgrade your site accordingly. Surfers have very short attention spans: they can afford to have, because they have thousands to choose from and they will often go visit another site, rather than figure out how yours works.

  • Links to other areas of your site are expected to be in the upper left of the screen.
  • Off-site links are expected to be on upper right of the screen or on the left, below the internal links.
  • “Home” links are expected: one at the top left of the screen and another bottom center.
  • Advertising banners are expected to be at the top of the browser window.
  • If you offer a search facility, it is expected to be in the top center of the screen.
  • If visitors may log in or register on your site, they should be able to do so from the upper left corner of the screen.
  • If you are selling merchandise and using a shopping cart, its links should be at the top right.
  • FAQ, help and contact links are also expected to be top right of the screen.

So the first rule when designing a site is to cater for rather than confound these expectations. However, some sites may have the chance to turn them to extra advantage because, when our well-trained surfer loads a new page, he or she instantly scans the first screen, paying particular attention to the locations which appear in the list above. So let’s say that your site doesn’t use a shopping cart: don’t simply leave the spot one would usually occupy empty or fill it with a non-productive graphic, put a small promotion, link or button, there. It will be seen.

Surfers’ expectation of a promo at the top of the screen should be of interest, particularly for the many who have become near paranoid about not exposing surfers to a sales pitch too soon. Certainly visitors should be able to see immediately that your site offers what they came for, but you can do that by telling them via text and/or graphics in a (shallow) header. Nor is it going to hurt – on a TGP for example – if at least a hint of the content is visible at the bottom of the first screen. But, never abandon the prime selling space on the page: confirmed freeloaders will not show you any appreciation and those who are looking to spend money may not bother looking down the page.

The moving finger writes…

(Note: never use obscure headlines) Some blogs and tours have in common their reliance on text and once again it is important to cater for the surfer who is far more likely to scan text than actually read it. Keep your text concise and on-topic, using short paragraphs with each covering a single salient point. Summarise that point in a few words if you can and highlight that text. Otherwise highlight key words. Less important is how you write, although it is best to aim for apparent objectivity rather than a hardcore sales pitch.

  • Use bulleted lists whenever possible and be generous with your line spacing.
  • Links with brief but informative descriptions are preferred to plain links or those with long descriptions.
  • Surfers prefer short summaries of articles to jumping straight into the full article.
  • Too much scrolling bugs surfers, so keep full articles on their own page(s) and don’t go overboard with the number of summaries displayed on one page. Blog owners take note!

Surfers’ dislike of scrolling may not seem entirely rational, but it is one of the main reasons that much of the content on many sites is rarely actually seen. In particular they hate horizontal scrolling and that creates a dilemma in the face of the wide variety of screen resolutions which need to be accomodated. Surfers using 800×600 may now be in a shrinking minority, but it is still a sizeable minority (15%-25%) while at the same time, a 760-pixel wide layout may keep them happy, but it will look puny at the higher resolutions.

Well the good news – at least if you are of an optimistic disposition – is that surfers prefer layouts which fill the screen. According to a number of surveys, full-screen layouts are considered more professional looking and easier to use. If you must go with a fixed layout, you should probably limit yourself to 900 pixels (to accomodate those who do not browse with a single window open) and at all costs, avoid layouts set to the left of the screen because those are actively disliked by many. And if you do impose horizontal scrolling on some, recognize most will not do it and keep important things, like navigation and promotions to the left of your page(s).

Olives: a Free WordPress Theme

“Olives” is a fluid 3-column WordPress theme, designed to perform best at 800×600 or 1024×768 but displays well at both lower and higher resolutions. The main column will handle images up to 380 pixels wide for display at 800×600 and at that resolution, the sidebars will handle images and promos up to 125 pixels wide. Accidentally oversized images should not throw the design out, but parts of such images will be hidden.

Olives theme

This theme is coded in validated XHTML strict and includes all the usual core templates. To replace the header image it is only necessary to overwrite the original file with a new one. Further styling changes should be easy for those with a reasonable knowledge of CSS, since the stylesheet file is structured so as to be straightforward to follow.

This theme is completely free. It includes a small credit in the footer and I would be grateful if it is left in place. To install, download the zip, unpack it on your PC, FTP the directories and files to your wp-content/themes directory and then activate the theme in your WordPress admin.

Ultimate Tag Warrior

Ultimate Tag Warrior (UTW) is described by its author as a “a multi-headed hydra of a plugin”, but unfortunately, having hinted at both its complexity and its potential, she offers very little in the way of narrative about her creation. This article is not intended as a comprehensive guide to UTW, but it should get you started.

Possible confusion begins with the terminology. “Tags” is used in the WordPress codex to refer to the placeholders located in templates so that dynamic information is displayed to your visitors. But from the perspective of UTW, “tags” means keywords which are assigned to each article to allow finer definitions than are generally available by the use of categories alone.

This explanation prompts the obvious question: why not just define more categories and/or sub-categories? The answer is that the majority of your visitors will not thank you if they have to peruse a list of 50 categories or if it takes more than 2-3 clicks at most to reach the content for which they are looking. It is therefore better to keep a quite short list of main categories and – if you use child categories at all – restrict their number (per parent category) even more. Off-topic, but worth mentioning is that yes, this limitation implies you should think very carefully before choosing your categories and subsequently make sure you allocate your posts to the most relevant categories (you can place a post in one, or as many categories as you wish).

Many visitors will be perfectly satisfied to browse via the category and archived (date) links, but just as some will use the search box, others will appreciate tags. In fact you could think of UTW tags as search boxes which have already been filled in. Let’s say for example you write a post which belongs in “Cars” and “Ford”, it may be relevant to add tags to that post of “experimental”, “hybrid”, “fuel efficient”. Clicking on one of those tags can pull up a page listing all the posts which have been similarly tagged, just as if the word had been entered in the search box.

The observant will have noticed that the word “can” was emphasized. That is because it is your choice whether tags point at off-site or on-site links and the decision as to which way to go depends largely on the type of site you have. If it is a resource site you may well be happy to include off-site links in order to make your site as useful as possible. For most other site types, internal links may be more appropriate.

Having mentioned off-site links, this is as good a place as any to also mention Technorati, a directory which lists sites based on the tags they display. Others such as Delicous operate this way, and although the traffic generated by these directories will vary according to the type of site you have and your skill at using tags, they can be substantial traffic sources. Another reason to use tags and a tool like UTW for working with them. Technorati – an article topic in its own right – does not require tags to point to it (they can be internal links or links to other third-party sites). You can even hide your tags if you think they clutter your pages and your visitors will not use them. For entry into its directory, Technorati only requires that your site and/or your pages is/are tagged.

The third reason to use tags is that once you have waded through the headache-inducing preliminaries, they are actually very easy to use and add an additional mechanism for helping search engines spider your blog as completely as possible. They also, by their existence, add extra relevant keywords to your site or reinforce those you are already targeting.

Summary of this article so far

  • Tags in this context are context-relevant keywords, user-selected on a per-post basis.
  • They provide an additional way for surfers to navigate site(s).
  • They are a must-have for listing in directories such as Technorati.
  • They provide further paths by which traditional search engines can spider site(s).

Before getting to the nitty-gritty of install and use, UTW has a further function which requires only an option box to be checked: namely that of automatically creating and inserting keyword meta tags for pages displaying list of tags and for single post pages. However that leaves the keyword meta missing on all other pages (a strange omission by WordPress even granted that this meta is not as powerful as in the past) and nothing taking care of the description meta tag at all. This plugin will solve all those problems and the same author has a useful page about keyword selection which will be a worthwhile read for many.

Installing and using UTW

The UTW plugin is installed as usual: download, unzip to your PC and then FTP the folder to your wp-content/plugins directory. Then activate the plugin from your WordPress admin, which will create a “Tags” link in both “Manage” and “Options”. Included on the Tags page are links to help files which have been installed on your own server and cover all the basic configuration and use issues, plus a link to the help pages on the author’s site.

As with most things WordPress, you are unlikely to actually break anything by testing the various options for yourself to see what they actually produce. But there are essentially two options for displaying tags and you can use one or both. The first is to display tags within posts by inserting [tag][/tag] around the keyword(s) you want to be treated as tags. The second, which you active via the tags management page, is to have tags automatically displayed at the end of each post.

The problem with this latter option is that they are displayed hard on the end of the post and styling does not always resolve that. Better, in my opinion, to set the automatic options off and add a line similar to this to the relevant template(s):

<div class="tags">Tags: <?php UTW_ShowTagsForCurrentPost("commalist") ?>

“ShowTagsForCurrentPost” is one of many ways of calling tags to be displayed according to certain parameters and in a particular format (and you control the styling through the class setting and your own CSS file). There are many more options on this page. You might also choose to display Technorati tags and related tags (although I prefer theRelated Entries plugin to the latter possibility):

<div class="tags">Technorati Tags: <?php UTW_ShowTagsForCurrentPost("technoraticommalist") ?><br />
Related Tags: <?php UTW_ShowRelatedTagsForCurrentTagSet("commalist") ?></div>

“Tag Clouds” can be created with UTW. These are ways of displaying all the tags on a site, using color and/or font size to highlight the tags which are used most often. The logic being that these links will return the most results. A good example can be found by scrolling down a screen on this page at Flickr. At the risk of offending some visitors, my personal opinion is that tag clouds are too geeky, not sufficiently intuitive for the average visitor to most sites. Therefore I usually think of them either as an additional means of navigation to be displayed fairly discreetly, or – more often – as primarily as giving the SE’s another way to find my more deeply buried pages. As such, placing the code to appear only at the very bottom of my home page is my most common choice, but however you do it, this is the code to use:

<div class="tagcloud"><?php UTW_ShowWeightedTagSetAlphabetical("coloredsizedtagcloud","","0") ?></div>

Once again most of the display style is controlled by your own style settings, but the font sizes and colors are set on the Tags –> Configuration page in your WordPress admin. The zero in that link says “display all tags” and replacing that with a positive number will impose a limit on the number of tags displayed. My example link is only one of many options: you can display graphs and bar charts, as well as other forms of tag cloud by choosing other link structures from the predefined formats page.

As mentioned above, I strongly recommend you try out different settings and different display formats, so you can actually see what they do. But these are the configuration settings I usually employ, that you can take as a starting point if you wish:

  • Use url rewriting for local tag urls (/tag/tag instead of index.php?tag=tag) = checked
  • Base url = /tag/
  • Include trailing slash on tag urls = checked
  • Include meta keywords = checked (unless using the Maxpower plugin mentioned above)
  • Use embedded tags = checked (whether I plan to use them or not)
  • Include debugging information = unchecked
  • Include local tag links in feeds = unchecked
  • Automatically include primary tag links = No (explained above)
  • Automatically include secondary tag links = No (explained above)
  • The tag cloud settings should reflect the colors of your theme and the placement of the tags. I often have my sizes set at 70% and 250% but that will not be right in many cases. Experiment!
  • Show existing tags on post editing page = checked (although this can become tiresome)
  • Automatically add categories as tags = checked

The last part of the process is that of adding tags to posts. As noted already you can put [tag][/tag] around keyword(s) and/or add tags to be displayed separately. After UTW is active, under your posting box will be a box for entering a comma-separated list of keywords (tags) for the post in question. You can do this manually and/or with some help from Yahoo. A couple of potential gotchas here. The first is that UTW also offers the same service from Tagyu, but Tagyu closed their site recently. The second is that the Yahoo button does not always work in Explorer: you may need to use a browser such as Firefox or Opera, to be to get tag suggestions reliably from Yahoo.

Last but not least, for Technorati to pick up multi-word tags, it is recommended that you join the words with an underscore – blue_car for example – and of course, if you are going for Technorati listings, make sure you use tags which exist in Technorati. That is another story for another day.

Update!

Since this article was written, both WordPress and UTW have gone through several versions and not all of them wanted to co-exist. However this site was updated in April 2007 and at the time of adding this comment, is running – without any problems – WordPress 2.1.3 and the latest version of Ultimate Tag Warrior.