How to delete Drupal menu item programmatically

Drupal Menu Delete

Sometimes we need to delete the menu item programmatically, so the below code snippet will help you to delete any menu item programmatically. You need to pass the menu id to the entityTypeManager service and you need to call the delete method.

$menu_link = \Drupal::entityTypeManager()->getStorage('menu_link_content')->load(3); // Pass Menu Id
$menu_link->delete();

 

Leave a Comment

Your email address will not be published.

Pin It on Pinterest

Share This