HI I’ve used the below code to add this function in menu as shortcode
function add_shortcode_to_last_menu_item($sorted_menu_items, $args) {
// Get the total number of menu items
$menu_item_count = count($sorted_menu_items);
// Get the shortcode you want to add
$shortcode = '[zeno_font_resizer]';
// Check if it's the last menu item
if ($sorted_menu_items[$menu_item_count - 1]->menu_order == $menu_item_count) {
// Append the shortcode to the last menu item title
$sorted_menu_items[$menu_item_count - 1]->title .= ' ' . $shortcode;
}
return $sorted_menu_items;
}
add_filter('wp_nav_menu_objects', 'add_shortcode_to_last_menu_item', 10, 2);
function zeno_font_resizer_place_shortcode() {
return zeno_font_resizer_place( false );
}
add_shortcode('zeno_font_resizer', 'zeno_font_resizer_place_shortcode');