Skip to content

Instantly share code, notes, and snippets.

@felixarntz
Last active December 28, 2015 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixarntz/7431266 to your computer and use it in GitHub Desktop.
Save felixarntz/7431266 to your computer and use it in GitHub Desktop.
<?php
function yourtheme_invalidate_nav_cache( $id )
{
$locations = get_nav_menu_locations();
if( is_array( $locations ) && $locations )
{
$locations = array_keys( $locations, $id );
if( $locations )
{
foreach( $locations as $location )
{
delete_transient( 'nav-' . $location );
}
}
}
}
add_action( 'wp_update_nav_menu', 'yourtheme_invalidate_nav_cache' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment