WordPress Single Post Templates

I’ve recently released a plugin that is far more robust than the methods outlined below. It actually duplicates the functionality of WordPress Page Templates, and allows you to create individual post templates, selectable on a per post basis via a dropdown menu. Head over to my WordPress Plugins page and find the “Post Templates Plugin”

UPDATED:
Austin recommends using a filter in your functions.php file as an alternative to the method below. IMO, his suggestion is much simpler and quite elegant. Here’s the code to add to your theme’s functions.php file. (be sure you paste this code between <?php ?> tags):

add_filter('single_template', create_function('$t', 'foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ) return TEMPLATEPATH . "/single-{$cat->term_id}.php"; } return $t;' ));

It helps solve the multiple categories issue since it cycles through all the categories in the array and checks to see which one of them has an associated post template. When it finds one, it uses the post template file, but if it doesn’t, then it falls back on the default single.php template.

So if you are used to placing posts in multiple categories, be sure to only create post templates for the categories you know won’t ever conflict.

Again, I highly recommend using this technique. It’s much simpler and works much better. If you care to, however, the original article is still below.
END UPDATE

A few months ago, I wrote a post over at the Blog Herald explaining how to set up and use WordPress Page Templates to control the way indivudual WordPress “Pages” appeared on your blog.  The process was pretty simple … create the page template, insert the necessary code at the top of the file, and upload it to your themes folder.

What what about blog posts?  As far as I could tell, there’s no way to do a similar thing with single posts without some manual code (see the “Unique Single Template” section).

Is it possible to have post templates like page templates???

Cory sent me this simple question a few days ago, and it got me thinking. So I started investigating. [Read more...]

IE Double Margin Bug

OK, I’ve just seen it plague too many designs and WordPress themes to ignore it anymore. I was completely oblivious to it when I started developing themes, and if you look at some of them, you’ll be able to tell it.

It’s … the dreaded IE Double Margin Bug!!!

The Problem

I’ll break it down … basically, on any floated item (for me, that would be the 3 main sections of a site, Content, Left sidebar, Right sidebar), no matter what margin you give the div, IE6 (maybe 7?) doubles that number. So if you have a left sidebar, floated left, along with a middle content section, also floated left, and finally a right sidebar, again … floated left, and you give them each a left and right margin of 10 pixels, IE will make it 20 pixels instead.

This comes as a HUGE problem when you have a fixed width layout, because too much margin on your floated columns will break your layout, causing a sidebar to fall down below the other columns.

A Solution

[Read more...]

Web-Safe Fonts For Your Blog

FontsNo matter what blogging platform you use … even if you’re just building a straight HTML website … there are relatively few fonts that are safe to use. You can’t just find a “pretty” font on your computer and use it on your website. You have to do your research first. Hopefully, this article will help you narrow down the choices in your quest to make your website bulletproof.

In basic CSS format, you define a font for a website like so:

body {
font-family: Arial, Helvetica, Sans-Serif;
font-weight: bold;
font-size: 12px;
}
[Read more...]

Know Your Audience: The Browser War

It never ceases to amaze me the different audience you see at different websites. Case Study:

For instance, this blog. I just recently launched this site as a means to release my WordPress themes and write tutorials and tips on web design, WordPress themes and blogging. Obviously, this blog appeals to a wide, but interestingly narrow audience. We’re talking about bloggers and designers, not amateurs.

Contrasting that, I did a WordPress theme for my church this past week to handle the new series called “GameTime“. It’s mostly using WordPress as a simple CMS to handle the various pages of content, but we also included a blog feature so we could publish updates to the members of the church. We’re not talking about a bunch of idiot visitors either. The people of NewSpring come from all kinds of backgrounds, including business professionals. [Read more...]