Hello Thai,
Thank you for helping. I used my shortcode with wp_nav_menu, but for a reason I don’t understand the menu was shown outside of the “OFF CANVAS”.
The code below worked for me:
function create_custom_mobile_menu() {
$menuLocations = get_nav_menu_locations(); // Get your nav locations (set in our theme, usually functions.php)
$menuID = $menuLocations['primary']; // Get the *primary* menu ID
$primaryNav = wp_get_nav_menu_items($menuID); // Get the array of wp objects, the nav items for our queried location.
foreach ( $primaryNav as $navItem ) {
$result .= '<li><a href="'.$navItem->url.'" title="'.$navItem->title.'">'.$navItem->title.'</a></li>';
}
return $result; }
add_shortcode('custom_mobile_menu', 'create_custom_mobile_menu');
Also I am able to customize the appearance of the menu.