Someone emailed me asking for advice on WordPress and how I created my site and static pages, it gave me an opportunity to write some stuff down that I had been meaning to share for a while, below is pretty much the email I sent in response.
A lot depends on what version of WP you want to run. My site is currently running a pre-release version of 1.3 which is still in alpha release (the sequence generally going alpha, then beta, then a final version), which has support for pages and themes, making it much easier to play about with. You can do all this with 1.2 (the previous version of my site ran 1.2), but it involves using much more custom coding ‘under the hood.’
First off, it’s probably best to explain about the mod-rewrite part of WP. This is done through a htaccess file in the main directory of your WP install, on Apache web servers at least (Linux/Unix hosts tend to run Apache), it doesn’t work on Windows servers. It’s a fairly commonly used approach to creating ‘nice URLs’ on sites that use some form of server-side coding (PHP, ASP, etc) to create their pages. These pages are created by passing variables through one page (index.php in our case), and the presence and value of a variable affects what the page displays. Normally this would result in a URL like:
The problem with this is that it shows everyone what sort of scripting your using, which has possible (but limited) security implications, and it’s not very friendly for either search engines (though most will index these sorts of pages) or end users. So, using mod-rewrite, you can use a more ‘friendly’ URL, say:
and get mod-rewrite to redirect the page in real-time, without changing what appears in the address bar of the browser, to:
This way, the server-side code gets the correct info to act on and the user still sees, and can visit a page, by using an easier to remember and more purposeful address. You don’t need to code each possibility into the htaccess file, just create a template for each possibility. I’m no expert on mod-rewrite, and even I’m not entirely sure how my code works, it just does. Any version of WP from 1.2 onwards will generate this code for you when you specify it under the options, just cut and paste, or, if WP 1.3 has enough privileges, it’ll do it all in the background without you needing to do a thing (i.e. it’ll create the file and put the necessary commands in it).
Right, on to the main course. I achieved ‘static’ pages in 1.2 by using statements that checked what category was called in the URL (i.e. which value was passed to is as above) and if certain ones were, or weren’t, called, it implemented a different layout (essentially calling the same code as for a single or archive page, but stripping it of the comment form, date, and other post data to make it look more like a page than a series of posts). My navigation was, and is, done by static links that link to categories or pages in the same format as the automatically generated links do.
I’ve annotated a copy of my old index.php file to try and help explain this, but can’t get it from my laptop onto an internet machine, so I’ll send it as soon as I can, but I don’t know when that’ll be. I would also recommend downloading the Kubrick template from http://binarybonsai.com/kubrick/ and having a play about. The Kubrick theme uses a lot of similar calls, though better laid out, to do things
like display messages on archive pages. Both the author of Kubrick and I use IF statemnents, but it looks like you can also do this with various IS statements, or so I believe, check out http://boren.nu/archives/2004/10/16/templates-and-the-is-functions/ for more info, but this may only be in 1.3.
In 1.3, things are entirely different. You just create a new version of the index.php, search page, archive page, static pages, single article pages, whatever, and store them in a directory under wp-content/themes and then this can be changed in the themes section of the WP administration console. To do this you need a CSS file in a separate directory under themes, with certain lines of (commented out) code that WP uses to define a theme and get the location of the other files. Check out http://codex.wordpress.org/Theme_Development for more info on themes and theme development.
Other than that, styling is done by adding or removing code from index.php (or individual template pages), and/or using CSS in the stylesheet. Design processes differ, but I generally try and look at what my site is delivering, and how best that’s done, and how the end-user will interact with it, then design around that. Template tags call the various functions and I tend to do a mock-up design, then thread the tags into the page where I want them to appear. For more info on the tags available and what they do, check out the WordPress Wiki, listed below.
Some WordPress resources you might find useful: