rozanchetta

Wordpress - Classe current para single do CPT

Sep 2nd, 2011
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. // ADICIONA CLASSE CURRENT PARA OS SINGLES DO CPT NO MENU - ADICIONE NO FUNCTIONS.PHP
  2. add_filter('nav_menu_css_class', 'current_type_nav_class', 10, 2 );
  3. function current_type_nav_class($classes, $item) {
  4. $post_type = get_post_type();
  5. if ($item->attr_title != '' && $item->attr_title == $post_type) {
  6. array_push($classes, 'current-menu-item');
  7. };
  8. return $classes;
  9. }
  10.  
  11. /* No painel do menu acrescente um link personalizado para a página do CPT - archive-cpt.php - e coloque o nome do CPT no atributo do título. A função acima utiliza o atributo do título para adicionar a classe "current". */
Advertisement
Add Comment
Please, Sign In to add comment