Wordpress菜单中插入短代码

方法1,在function.php中添加以下代码:

 add_filter('nav_menu_item_title', 'do_shortcode');

方法2,function.php中添加以下代码:

add_filter('nav_menu_item_title', function ($title, $item, $args, $depth) {
    return do_shortcode($title);
}, 10, 4);

方法3:搜索安装 Shortcode in Menus 插件
https://wordpress.org/plugins/shortcode-in-menus/