Category Post Templates


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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;' ));

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.