Posted By

creativelifeform on 05/17/10


Tagged

wordpress


Versions (?)

Category Post Templates


 / Published in: PHP
 

URL: http://www.nathanrice.net/blog/wordpress-single-post-templates/

This will let you define individual templates for posts within specific categories. Simply name your post file like: single-SLUG.php

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

Report this snippet  

You need to login to post a comment.