Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save reatlat/dc702631dd7fe516846f7b63eb070f84 to your computer and use it in GitHub Desktop.
Save reatlat/dc702631dd7fe516846f7b63eb070f84 to your computer and use it in GitHub Desktop.
Remove all WordPress theme_mods but keep menu locations
// Get menu locations and save to array
$locations = get_theme_mod( 'nav_menu_locations' );
$save_menus = array();
foreach( $locations as $key => $val ) {
$save_menus[$key] = $val;
}
// Remove all mods
remove_theme_mods();
// Re-add the menus
set_theme_mod( 'nav_menu_locations', array_map( 'absint', $save_menus ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment