groups

name language licence
featured sliding content PHP BSD
How to change the default Wordpress excerpt PHP BSD
Display an External RSS Feed PHP BSD
WORDPRESS STATIC HTML TEMPLATE PHP BSD
CUSTOM TEMPLATES FOR POSTS IN WORDPRESS PHP BSD
WORDPRESS: LATEST POSTS FROM CATEGORY PHP BSD
Better more link PHP BSD
WORDPRESS INCLUDE PAGE CONTENT PHP BSD

< 1 2 >



language: PHP
licence: BSD

CUSTOM TEMPLATES FOR POSTS IN WORDPRESS

options: view full snippetsend to code collector
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');
	
(Continues...)