While completing the FAQs chapter in a WordPress themes book I wrote, I came across this question: How can I install a WordPress theme update as a new, separate theme without overwriting the old theme? I never understood why people wanted to do this, but I have been asked this more than a few times. This post is an excerpt from my book’s FAQ section.
Zipping up theme files
If you take a group of files and compress them into a .zip file, the zip file will have a name given to it by the operating system (Macs use “Archive.zip” to name a group of files.) When you unzip “Archive.zip” it will create a folder called “Archive” so as to not drop a bunch of files all over the place (even if you didn’t start with a folder called “Archive.”) Let’s say you renamed Archive.zip file to “awesome_theme.zip.” When you unzip “awesome_theme.zip” it will automatically create a folder called “awesome_theme”.
If you take a single folder named “awesome_theme” and compress it into a .zip, it will name the .zip file “awesome_theme.zip.” When you open the .zip file it will create a folder named “awesome_theme.” If you were to change the name of the .zip file from “awesome_theme.zip” to “test.zip”, you would still get a folder called named “awesome_theme” when you unzipped it.
Got it? It’s important to get that straight for when you go to create .zip files to upload.
Common usage: WordPress (and some other theme developers) wrap their themes files in a folder with a specific name they use for all versions, like “twentytwelve.” When they zip that folder up, they often rename the .zip file to show what version it is, such as “twentyeleven.1.6.zip.” So, the .zip file has a folder inside it that contains the theme files.
In short: Compress loose files and the zip file will uncompress to make a folder based on the zip file’s current name. Compress a folder, and no matter what you change the .zip file’s name to it will always uncompress showing the original folder’s name. WordPress is simply uncompressing the .zip file, so the name of the folder it creates is important and you want to control that for when you want to install an update as a separate theme.
Test #1 – failed
- I changed the theme’s name by going into the style.css and changing the text listed in the “Theme Name:” part of the stylesheet header (very top.) In this case it was “Twenty Eleven”, and I changed it to “Twenty Eleven Test”. I then zipped up the theme files as “twentyeleven.zip.”
- I uploaded the .zip file via the Appearance > Themes > Install Themes > Upload screen, but after a few seconds it stated “Destination folder already exists. … Theme install failed.” Ok, so the Theme Name attribute isn’t enough to make it be seen as a new, separate theme.
- I looked at the .zip file I am uploading and it is named “twentyeleven.zip”, with no subfolder that contains the theme files. Like I said above, this last part is important: in this case WordPress will use the .zip file name to create a folder.
- So, when WordPress unzips the file it creates a folder called “twentyeleven.”, which (for this test) already exists in the theme folder. We cannot have two folders named the same thing, WordPress stops you from overwriting the existing “twentyeleven” file.
- I went one step further and tried uploading an update of the Twenty Twelve theme to see if WordPress would allow me to overwrite the old folder. I had Twenty Eleven version 1.5 installed and was uploading Twenty Eleven version 1.6 (that I downloaded from WordPres.org) as a new theme. WordPress stopped me and said “Destination folder already exists. … Theme install failed.”
Test #2 – worked!
- I changed the name of the .zip file from “twentyeleven.zip” to “twentyeleventest.zip” and uploaded it. It worked because when WordPress unzipped the file it created a folder called “twentyeleventest”, which doesn’t already exist.
- Now I have two ‘Twenty Twelve’ themes, one as version 1.5 and the other version 1.6.
- Interesting thing happened when I viewed the Themes screens: WordPress lists the theme name as “Twenty Eleven/twentyeleventest.” Since the “Twenty Twelve” theme already exists in the database, WordPress keeps them separated by renaming it for the Themes screen.
The takeaway is that no matter how you created the .zip file, you have to make sure the folder WordPress is going to create when unzipping it is uniquely named and not the same as any other folder in the themes folder on your server.
Why not just FTP it to the server?
Yep. That’s how I would get around this whole mess. But, unfortunately not everyone is savvy in the ways of FTP or even using their cPanel file manager to simply upload a uniquely named folder to the wp-content/themes folder. This .zip guide is for people who only know how to use the WordPress Admin Panel to manage themes.
Know that widgets and Customize options don’t traverse. When you have two of the same themes installed with different versions: widgets and some options in the Customize screen don’t traverse when you switch to the new theme. This will mean you taking some time to set those options, widgets and customizations up again.
If you know of a better or easier way, or have corrections to the tutorial above, let me know in the comments below, or contact me.
I had something similar I did change zip name Folder name but it said error message about directory.
I am going to try it again.