Advertisement
mukto90

category-slug based single post template for WordPress

Mar 8th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.32 KB | None | 0 0
  1. //creates category-slug based template for single post
  2. add_filter('single_template', create_function(
  3.     '$the_template',
  4.     'foreach( (array) get_the_category() as $cat ) {
  5.         if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") )
  6.         return TEMPLATEPATH . "/single-{$cat->slug}.php"; }
  7.     return $the_template;' )
  8. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement