Return to Snippet

Revision: 26976
at May 26, 2010 18:34 by creativelifeform


Updated Code
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;' ));

Revision: 26975
at May 17, 2010 20:23 by creativelifeform


Initial Code
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;' ));

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

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

Initial Title
Category Post Templates

Initial Tags
wordpress

Initial Language
PHP