Created
June 20, 2012 07:35
-
-
Save trico/2958648 to your computer and use it in GitHub Desktop.
Añadir una clase para cada uno de los elemento de wp_nav_menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function new_nav_menu_items($output) { | |
$idstr = preg_match_all('/<li class="page_item page-item-(\d+)/', $output, $matches); | |
foreach($matches[1] as $mid){ | |
$slug = basename(get_permalink($mid)); | |
$output = preg_replace('/page-item-'.$mid.'(| current_page_item)">/', 'page-item-'.$mid.' page-item-'.$slug.'">', $output, 1); | |
} | |
return $output; | |
} | |
add_filter( 'wp_list_pages', 'new_nav_menu_items' ); | |
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment