Popular post

About

Blog sobre diseño y desarrollo web.
Códigos o enlaces que me han sido útiles en mi trabajo como desarrolladora web :)

lunes, 3 de febrero de 2014

Mostrar diferente template single.php por slug

Añadir a funcitions:

function get_category_post_template($single_template) {
global $post;

$categories = get_the_category($post->ID) ;

foreach ( $categories as $cat) {
if (file_exists( dirname( __FILE__ ) . "/single-{$cat->slug}.php" ) )
$single_template = dirname( __FILE__ ) . "/single-{$cat->slug}.php" ;
}
return $single_template;
}

add_filter( "single_template", "get_category_post_template" ) ;