Extending WordPress’ Template Hierarchy with Single Post Templates

For my personal site, I was looking for a way to use a specific template for posts that had a specific category applied. WordPress’ template hierarchy doesn’t support this type of need – the only taxonomy-type templates that WordPress looks for are for taxonomy archives.

I went hunting for a solution, and came across Justin Tadlock’s neat little write-up, “Creating single post templates in WordPress”. In it, Justin provides sample code on how to extend WordPress’ template hierarchy. His example not only applied to my situation, but for single posts in general, allowing for IDs, tags, categories, and even authors!

As is typical of Justin’s writings, the post not only includes the sample code but a well-written explanation of the need for it and how it works.

Although the post was written in 2008, the filter and logic still apply. Thanks for the solution Justin!

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *