How-To create templates for individual posts using WordPress

How-To create templates for individual posts using WordPress

I simply adore stuff like this. While it took me 15 or 20 minutes to figure out what they were talking about, once I did it was both elegant and easy to replicate. Open Source Rocks!

The Problem

WordPress allows you to easily create templates for “Pages” and entire categories. This is very handy and easy to implement.

WordPress does not make it easy to create a template for a single post.

In my case, I needed the first post in a category to have a special link for the “previous-link” navigation. Additionally, the last post needed the same link for the “next-link” navigation. (Normally, the first post would have a blank right navigation since there is no previous post and the last post would have a blank left one since there is no next post.)

The Solution

In order to create a category template you have to name the template file category-n.php where “n” is the category ID. [Hint: Select Manage > Category > Your Category and then look at the URL – it will contain the category ID!]

Well these guys figured out how to do the same thing by creating similar category templates and then assigning your post to that category. The >>REALLY<< cool and elegant thing is that the "update" by Austin allows you to place a post in multiple categories (the real one and the template one).

Thanx gentlemen!

Permanent link to this article:

Leave a Reply