Automatically remove trashed pages from nav menu

As it is now, when a page that is in the nav menu is trashed, it still stays in the menu until manually remove via the nav menu editor. Is it possible to have trashed pages removed automatically?

Thanks

2 Answers
2

Just hook the default delete_post handler for menus onto the trash action too:

add_action( 'wp_trash_post', '_wp_delete_post_menu_item' );

How simple is that!

Leave a Comment