How to hide menu links

If you want to hide links for the custom menu, the best way to do it is to use special function. Add this code in file functions.php of child theme or in plugin FunctionsPHP previously change id main-menu at 3 string to your menu ID:

function myslug_hide_links( $items, $args ) {
	
	if( $args->theme_location == 'main-menu' ){
	
		$items = str_replace(
			array( '<a', '</a>' ),
			array( '[link]<a', '</a>[/link]' ),
			$items
		);
	
		$items = do_shortcode( $items );
	}
	
	return $items;
}
add_filter('wp_nav_menu_items', 'myslug_hide_links', 10, 2);

If you want to hide links for ALL custom menus, the best way to do it is to use special function. Add this code in file functions.php of child theme or in plugin FunctionsPHP:

function myslug_hide_links( $items, $args ) {
	
	$items = str_replace(
		array( '<a', '</a>' ),
		array( '[link]<a', '</a>[/link]' ),
		$items
	);
	
	$items = do_shortcode( $items );
	
	return $items;
}
add_filter('wp_nav_menu_items', 'myslug_hide_links', 10, 2);