Created
June 26, 2012 15:59
-
-
Save davekuhar/2996674 to your computer and use it in GitHub Desktop.
Add 'first' and 'last' to WP navigation
This file contains hidden or 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
| add_filter('wp_nav_menu', 'add_first_and_last'); | |
| function add_first_and_last($output) { | |
| $output = preg_replace('/class="menu-item/', 'class="first-menu-item menu-item', $output, 1); | |
| $output = substr_replace($output, 'class="last-menu-item menu-item', strripos($output, 'class="menu-item'), strlen('class="menu-item')); | |
| return $output; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment