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?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
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!
You'll need a plugin which:
Adds a method to the
deleted_post action (taking the page's id)
Filters: the action is used for posts etc. as well.
Updates the menu by
wp_get_nav_menuto get its items