I’m trying to add an item to a sub menu via functions.php as the item will change based on the users logged in status and subscription status.
Here is the code I use to add an item to the menu:
add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
function your_custom_menu_item ( $items, $args ) {
if (is_single() && $args->theme_location == 'primary') {
$items .= '<li>Show whatever</li>';
}
return $items;
}
However, does anyone know how I would add an item to a submenu?
You can use add_menu_subpage wordpress’ function.
Reference: http://codex.wordpress.org/Function_Reference/add_submenu_page