I was building a theme for a client the other day (yes, I have to get around to actually building one of my own for this site) and I was at a loss for how he wanted his website layout to flow: he wanted separate pages for each category he had in his blog so he could go into more detail. Donning my programmer cap, I figured it would take some serious coding to get this feature implemented, but a quick trip to the codex proved me wrong. The smart fellows over there anticipated this and developed a system to deal with blogs that have specific category customization needs, or those with no needs at all, who don’t want extra stuff cluttering their theme.
Category presentation in Wordpress is modeled from specific to general, that is, when presenting content for a specific category, Wordpress is going to first look for a category page that contains the ID of the category in question. For example, let’s assume we had a category for trees that had an ID of six. When presenting the content, Wordpress looks in your theme directory for a page named category-6.php . If it does not find a page like that, it degrades to the next most specific page for categories: category.php . Let’s assume again that we never got around to creating THAT page, the system then degrades and looks for: archive.php. But, we were really lazy, and never made an archive page. Well the system is smart enough to compensate for that, and degrades all the way back to index.php.
Check out the codex for a complete overview of category pages and their implementation in Wordpress.
A fantastic piece of software in Beta that is an excellent way to manage your blog (or blogs) from your desktop. The Wordpress crew did a great job when they redid the admin side (2.0+) and they added a rich-text editor, but it still has some quirks that just bug me. Yes, I’m soaking in it, er, I mean I’m using it to post here. And I really like it - I’ve always felt uncomfortable using a browser-based admin interface for a really long post. I’m always scared that it will hiccup and all of my work will be lost (after a particularly rage-inducing incident years ago). Windows Live Writer seems to me to be a spiritual successor to w.Bloggar, with obvious improvements. And that’s a good thing since the w.Bloggar project seems to be MIA. Add in the fact that this sucker has a spell-checker, and I’m sold. I hope they make it cheap enough that I can afford to pick up a copy when its released, because, unfortunately, I’m hooked.
I’m sure that if you’ve ever decided to build a theme in Wordpress, you’ve had to deal with the The Loop. The Loop is the structure that really is at the heart of the blog engine and looks something like this:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
�.
<?php endwhile; ?>
<?php else : ?>
�.
<?php endif; ?>
(The dots, being the code you use to process each of the individual posts.)
Of course, this is all well and good, but if you’re a beginner to PHP, I’m sure you are a bit confused as to what you are seeing. What are those colons doing there, are where are the curly braces? The answer is that our example is utilizing alternative control syntax in PHP to make the code just a bit more readable. Other templating systems, such as Savant, use this inside templates to make it easier to read where loops and logic statements end. After all endwhile is easier to see at a first glance than a curly brace �}� when reading code mixed with HTML, which describe templates to a ‘T’.