Mika MAtikainen
Apr 15, 2020 · 4 min read
Disable theme switching
By default WordPress enables users to switch themes while working in the Admin area. Sometimes a user might screw this up and accidentally activate the wrong theme.
To prevent this, add the following code to your functions.php file:
[code lang=”php”]
function remove_theme_menus() {
global $submenu;
unset($submenu[‘themes.php’][5]);
unset($submenu[‘themes.php’][15]);
}
add_action(‘admin_init’, ‘remove_theme_menus’);
[/code]
Technically theme switching will still be possible, but this code will prevent mistakes by disabling WordPress theme menus. Good times.