WordPress themes can have a child theme. Meaning, you can duplicate the main theme and make your changes in it. In this case, the main theme will be intact and saved as a backup.
Designers and developers that make changes to WordPress tend to create a child theme from the parent theme. Because, if anything goes wrong or the website breaks, the main theme is untouched and you can just activate it and re-create the child theme again.
In this article, we would like to discuss how to hide the parent theme in WordPress by three easy methods. But before we begin, let us explain why should we even hide the parent theme in WordPress?
Why Hide Parent Theme in WordPress
The main and most important reason for hiding the parent theme in WordPress is for security purposes. As you probably know, the parent theme is always used to get backups.
There may be some people aside from you who have gained access to the theme editor. For example, your editors, other admins, etc. In this case, it’s best to create a child theme and apply your changes there and limit the access to the parent theme.
On the other hand, due to security reasons, you may have renamed the child theme just to hide the parent theme.
Manually Hide Parent Theme in WordPress
The main method to hide parent theme in WordPress is by using a function in the website’s code. In this method, we are going to modify the core files and code of WordPress. Therefore, we highly recommend getting a full backup of your website to prevent any data loss.
Let’s begin.
There is a filter called wp_prepare_themes_for_js in the wp-admin/includes/themes.php. This filter is called upon by wp-admin/themes.php for theme configuration.
By using this filter, you can easily hide parent theme in WordPress. However, you need to know the exact name of your theme and put it in the code.
function kill_theme_wpse_188906($themes) {
unset($themes['twentyten']);
return $themes;
}
add_filter('wp_prepare_themes_for_js','kill_theme_wpse_188906');
Hide Parent Theme in WordPress from The Dashboard
If there is no need to hide the parent theme, you can simply rename it. To summarize:
- Go to your hosting panel (cPanel) and head to wp-content/themes. Rename the parent theme to any other name.
- In the next step, open the folder and look for the style.css file. Open the file, you can see the theme name, you have to rename it as well. (you can use any other name)
- Now go to the WordPress Dashboard go to Appearance > Themes. Enable the theme with its new name.
- This is an extra step if you are using a child theme or the parent theme. Other than renaming the parent folder, you have to rename it in the child theme’s files as well.
Hide Parent Theme in WordPress using a Plugin
Another method to hide parent theme in WordPress is by using a plugin. One of the best and most suitable plugins you can use is the WP Hide & Security Enhancer plugin. With this plugin, you can hide the core files of WordPress, plugins, and themes.
To download WP Hide, simply head over to the official WordPress website or download it directly from the Plugins>Add New in the WordPress dashboard.
This plugin works very smoothly and completely hides the theme. It also hides the additional information in the style.css file and leaves no trace behind.