Skip to content

Instantly share code, notes, and snippets.

@xafarali
Created June 10, 2013 02:28
Show Gist options
  • Save xafarali/5746162 to your computer and use it in GitHub Desktop.
Save xafarali/5746162 to your computer and use it in GitHub Desktop.
Custom Menu Items
add_filter( 'wp_nav_menu_items', 'custom_menu_item', 10, 2 );
function custom_menu_item ( $items, $args ) {
if ($args->theme_location == 'primary') {
$items .= '<li>This is Custom Menu</li>';
}
return $items;
}
// custom first and last class
function wpb_first_and_last_menu_class($items) {
$items[1]->classes[] = 'first';
$items[count($items)]->classes[] = 'last';
return $items;
}
add_filter('wp_nav_menu_objects', 'wpb_first_and_last_menu_class');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment