Advertisement
miriamdepaula

WordPress: "Template Redirect" para singles de diferentes categorias

Sep 6th, 2011
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. function redirect_singles() {
  2.     if(is_singular()){     
  3.       $category = get_the_category();
  4.       $currentcat = $category[0]->slug; //verifico o slug da categoria
  5.       if (file_exists(TEMPLATEPATH."/single-$currentcat".".php")) {
  6.           include(TEMPLATEPATH."/single-$currentcat".".php");
  7.       }
  8.     }  
  9. }
  10.  
  11. add_action('template_redirect', 'redirect_singles');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement