We have the following code that is used to hide our core theme so that it can't be enabled directly and you can only enable the child themes from the WordPress Dashboard.

function hide_core_theme($themes) {
    return $themes;
add_action('wp_prepare_themes_for_js', 'hide_core_theme');

However if you put this code inside the functions.php file of either the Parent or Child theme it will only hide the core theme when one of them is enabled... e.g. if someone was to turn on another theme the core theme would appear again.

Another option is to add this code inside a custom plugin... but it means having it enabled and a user could always disable this plugin to get around it... plus we're not too keen on having a plugin to turn off a theme as it feels pretty detached.

Is it possible to add some hooks that are outside of a Theme or Plugin? And therefore are called regardless of what themes or plugins are enabled?


You want a "Must Use Plugin". Any PHP files placed in wp-content/mu-plugins will be run automatically, and can only be 'deactivated' by removing the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.