how to rename or change the theme name in wordpress

Themes are one of the most important part or feature of WordPress. Themes are an easy way to "skin" your website and provide it an unique design and layout with out having to modify any of the underlying code. Most themes are usually plug-and-play, meaning it can easily be installed and activated using the WordPress UI.

Many of the well-designed themes are also quite customizable. You can usually modify several different features such as the font, color and element sizes without modifying any code. You might also be able to modify some parts of the layout depending on how it is designed and what customizations the theme developer had provided.

It is not so uncommon to find that some part of the theme is not customizable to the point you want to. Most times, you should consider developing a custom theme instead of modifying the theme. Other times, depending on how much you need to change you can develop a child theme. There are several advantages to developing a child theme rather than modifying the theme itself.

For some reason, if you did end up modifying the theme itself then you might want to change theme name as well, so as to avoid conflicts. Changing the theme name is usually not one of the features provided by the theme. We will see how you can easily change the name of the theme if and when needed.

Backup

First thing to do is to backup the theme folder and files to a location outside the WordPress install location. The path to the theme folder is mostly likely to be /<path to wordpress>/wp-content/themes/<themename>. Copy the entire folder to another location elsewhere in the file system.

Deactivate Theme

You will now need to deactivate the theme that you want to rename, if it is currently being used. You can do so by activating another theme, such Twenty Fifteen (or a default theme) for the time being. You can do so from the admin UI.

Go to Dashboard -> Appearance -> Themes and click on Activate button on the new theme.

Rename the Folder

The next step is to rename the folder of the theme. For example, change the folder name to something more appropriate with the new theme name. It does not necessarily have to match the theme name, but keeping it close to the theme name will be helpful.

Rename Theme in style.css

Now open the style.css file in the themes top folder. The top of the file contains the information about the theme inside the comments. You can modify each field in the comment to suit your needs. Most of the fields should be self-explanatory. A sample from the Twenty Fifteen theme looks like this

/*
Theme Name: Twenty Fifteen
Theme URI: https://wordpress.org/themes/twentyfifteen/
Author: the WordPress team
Author URI: https://wordpress.org/
*/

Ideally, that is all you need to do in a well-designed and well-implemented theme. But most themes are not really well-coded and it is not rare to find that the theme names have been hard coded into several other files. It also depends on how much of it you want to hide from the user.

You will need to search through the all the files in the theme folder to make sure that the name is not coded elsewhere. You can easily use find and grep commands in Linux to do so. A typical example to do so will be

$ find /path/to/themefolder/ -exec grep -i "Old Theme Name" "{}" \;

Now go through each of the results returned by the command and replace each occurrence with the new name. You can probably use sed or awk command along with the command above to do that. An example is shown below to change the theme name from Twenty Thirteen to TT Theme., be sure to substitute theme names and options that you need.

$ find . -exec sed -i -- 's/Twenty\ Thirteen/TT\ Theme/g' "{}" \;

Now, search again and make sure that there are no remnants of the name left in any files. Now, go back to the themes page in WordPress admin UI and check that there is a new theme with the new name. Now, try to activate the new theme and make sure that everything works.

If there are any issues with the theme or had any spelling mistakes then you might have to start over again. Well, You did back up the theme …didn't you?