23 October 2009

The Single Post Template in WordPress

Like me, many of you loved the ability to create and display a separate template for each page content in our WordPress blog. Each template may return or display a separate php script either from the built-in function of WordPress or from a third party script (just like Simplepie).

But what about posts (under the single.php)?

If you'd like simulate the capability of creating a different template for Page Templates, then this plugin (Single Post Template) could be your best bet. Templates can only be assigned on a per post basis. So you have to edit your earlier posts that you want to be displayed in your new specific template.

I have some reservations for this method, though, as this is a plugin in the first place. What if I upgraded and it isn't compatible with the future versions of WordPress anymore.

But, if you want to display a different template for each post under a certain category, and to affect all posts previously posted filed under the same category, then these hacks could do well:


There's a caveat with the last item, though; to wit:
Like I mentioned earlier, if you are in the habit of filing posts under multiple categories, this code probably won’t work as intended. Since we’re working with templates for use on single posts in single categories, posts in multiple categories may end up falling back to the default single.php template. You have been warned!

No comments:

Post a Comment