wordpress php hardcode item to submenu

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:

Read More
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?

Related posts

Leave a Reply

1 comment