Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Adding first and last class to nav menu items
- function nav_menu_first_last( $items ) {
- $position = strrpos($items, 'class="menu-item', -1);
- $items=substr_replace($items, 'last ', $position+7, 0);
- $position = strpos($items, 'class="menu-item');
- $items=substr_replace($items, 'first ', $position+7, 0);
- return $items;
- }
- add_filter( 'wp_nav_menu_items', 'nav_menu_first_last' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement