Themes are one of WordPressโ main selling points. However, they can sometimes break, cause issues with plugins, or with other elements on your website. In those cases, you might need to change your active theme, but it could be difficult to do so if you donโt have access to your dashboard due to an error.
The good news is there are workarounds for this problem. You can, for example, change themes through the database in a matter of minutes, if you know where to look. In this article, weโll talk about some situations where you might need to do this, and then weโll guide you through the process in three steps.
Letโs get to it!
Subscribe To Our Youtube Channel
Why You Might Need to Disable Your Active WordPress Theme
Under normal circumstances, changing your WordPress theme only takes seconds. All you need to do is choosing which theme to use and activating it.
These days, a lot of themes try to outdo each other when it comes to features, to attract as wide a user base as possible. In a lot of cases, they use JavaScript or jQuery, which can sometimes lead to conflicts with some of your plugins. These conflicts can cause specific functionality to stop working or, if youโre really unlucky, they may leave you unable to access your site or dashboard at all.
In these cases, youโll likely need to change your theme. The problem is, if you use FTP to disable your theme, WordPress wonโt let you choose which theme to use instead and will automatically set one of the default themes. Thatโs why it can make more sense to change themes through the database instead. With this process, you have full control over which theme to enable.
Before you try this, we recommend you try to troubleshoot your plugins first, be it via FTP or your database. In our experience, itโs often easier to replace one troublesome plugin or two instead of switching themes altogether. However, your mileage may vary, so it doesnโt hurt to have this trick up your sleeve, just in case.
How to Change Your Active WordPress Theme Through Your Database (In 3 Steps)
Since weโre going to be making changes to your database (albeit small ones), it would be wise to create a backup of it just in case. Migration plugins like UpDraftPlus andย BackupBuddy make the process very simple. That way, if something goes wrong, you can restore it via phpMyAdmin.
Step #1: Access Your WordPress Database With phpMyAdmin
Weโve covered this process in the past, so letโs keep it quick. If youโre using shared hosting, chances are your provider uses cPanel for your plan. In that case, you can access your WordPress database via phpMyAdmin by logging into your cPanel and finding that option under the Databases section:
Once youโre in, look for the database that corresponds to the website you want to troubleshoot. If youโre only hosting a single site on your plan, there should only be one option to the left. In the example below, you can see several databases. However, the next steps wonโt change regardless of which siteโs database you access, as long as it uses WordPress.
If youโre not using a shared plan, take a look at your hosting providerโs control panel. Most platforms will provide you with a way to access and edit your database, even if you donโt have cPanel set up.
Step #2: Find Where WordPress Stores Your Active Themeโs Value
WordPress stores all your websiteโs information in a single database, including which theme youโre using. Your job then is to find where that value resides in your database and change it.
Once you choose the database you want to edit, youโll see a list of all the tables WordPress uses to store its data. The one weโre interested in is usually called wp_options:
Keep in mind โ some hosting providers change your database and table prefixes from the default wp for security purposes, as in the example above. In any case, these changes donโt affect the way your database works. Moving on โ click on the wp_options table and on the next page, tick the box that says Show all at the top of the screen:
What this does is display all the wp_options rows in the same page, so you can find the ones youโre looking for without jumping back and forth. Now, use your browserโs search function to find the template value under the option_name column:
Youโll notice we highlighted two rows in the screenshot above, both of which show twentyseventeen under option_value. To change your theme, we need to edit both rows. However, before we do that, you need to know what value to replace your current theme with, which brings us to the next section.
Step #3: Change Your Active Theme
All you need to do now is edit the values we showed you earlier under both the template and stylesheet rows. The problem is, you canโt just type the name of the theme you want to use.
If you type the themeโs full name, WordPress wonโt know what youโre talking about, and youโll run into an error. For example, take the Twenty Seventeen theme, which shows up as a single word, twentyseventeen. This is often not a problem with themes that have single-word names, such as Divi.
However, in some cases, youโll need to do a little digging to find out which value to use on your database. There are a couple of ways to do this. If the theme you want to use is on the WordPress.org theme repository, you can find an option called Development Log under the Browse the Code section on its page:
If you click on this option, youโll see a page showing the themeโs update record. At the top of the screen, youโll see a subheading that says source, with the themeโs development name next to it:
In the example above, we check out the Clean Education theme, and found out it goes by the clean-education name. The latter is the value youโd want to use to enable it from your database. You can also find out this information by accessing your website via FTP and navigating to the public_html/wp-content/themes directory. Inside, youโll find folders for each theme installed on your website:
Each folderโs name reflects how WordPress recognizes those themes. For example, if you wanted to switch to Divi using your database, youโd need to enter โdiviโ as the value. Letโs go ahead and do that now. Return to your database and click on the Edit button to the left of the template row:
On the next screen, look for the option_value field and replace its contents with divi:
Now click on the Go button at the lower right of the page to save your changes. Repeat that exact same process for the stylesheet row within your wp_options table. Once youโve updated both values, you can go ahead and access your website, which should now be using Divi.
Conclusion
If your WordPress theme is giving you problems, the easy fix is to temporarily disable it, which youโd usually do through your dashboard. If you canโt access the dashboard, you may need to use your database instead. This is a bit trickier, but it also enables you to specify which theme to use.
To use your database to change your active theme, youโll need to follow these steps:
- Access your database using phpMyAdmin.
- Find where your database stores your themeโs value.
- Switch your active theme with another one of your choice.
Do you have any questions about how to change themes through the database? Letโs talk about them in the comments section below!
Article thumbnail image by ProStockStudio / shutterstock.com
Does changing WordPress themes affect your website’s ranking on google?
Management under folders with WP
Hi, I try to explain, I’m trying to solve a passage that from what I could notice documenting penalizes the visibility of the site on Google with poor visibility, from 0 to 3 daily visits.
The site laspesacasa.it offers the sale of typical products made with WordPress, for logistical reasons and not being able to manage the products I personally created sub-domains.
So the site laspesacasa.it and the parent site and the various subdomains nomedelproduttore.laspesacasa.it are the producers who have different shipping and administration fees, all done with woocommerce.
What I ask is possible to manage everything from the parent site (I do not know if it is the exact wording – tracking code). Example, laspesacasa.it/produttore and within the subfolders manage the woocommerce of the single producer with the different logistical and administrative needs.
Can you help me, need a programmer’s intervention or are there other solutions?
Thank you
Thanks for this Post.
I’ve had to do a similar thing for the Active Plugins(much different update for the value of the ‘option_name’ for plugins).
I did not know which values to look for in the ‘option_name’ field for the themes. And I would have forgotten to consider the StyleSheet, so thanks for the extra info.
You’re welcome, Greg! ๐
This is definitely a good trick to add to the arsenal! I usually just rename the active theme’s folder via ftp but this is way better being able to choose what it defaults to. Thanks for being so detailed about it, I think matching the theme’s exact folder name to the database value would’ve probably tripped me up!
FTP is usually a fine way of doing it, but it might not always be possible. I’m glad you enjoyed the article. ๐
This is a life-saving article. My website was giving an error while changing the theme and I was not able to access my WordPress admin area to change the theme. I have followed your entire guide fixed this problem through my CPanel area.
I’m really glad to hear it was useful! ๐