I need to insert a menu in the text of one page. I found these two plugin but none of them work. Both of them haven't been updated for 6 years:
https://wordpress.org/plugins/custom-menu/
https://wordpress.org/plugins/custom-menu-shortcode/
I found this code to create my own shortcode
function print_menu_shortcode($atts, $content = null) {
extract(shortcode_atts(array( 'name' => null, 'class' => null ), $atts));
return wp_nav_menu( array( 'menu' => $name, 'menu_class' => $class, 'echo' => false ) );
}
add_shortcode('menu', 'print_menu_shortcode');
And then shortcode should be:
[menu name="-your menu name-" class="-your class-"]
It works but the class is not printed at all. What is wrong in the function? I need to print the class.