custom templates for posts

function custom_template($template) {
global $wp_query;
$cats = get_the_category($wp_query->post->ID);
$cat = $cats[0];
if (file_exists(TEMPLATEPATH.”/category-“.$cat->cat_ID.’.php’)) {
return TEMPLATEPATH.”/category-“.$cat->cat_ID.’.php’;
}
return $template;
}

add_filter(‘single_template’, ‘custom_template’);


custom templates for posts