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


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.