Here is how to manually change the WordPress theme to a default (Twenty Fifteen) in database. Do not use this method if you are not familiar with manually editing your WordPress Database in phpMyAdmin.
The three option_name
rows in the database that need to be changed. These are what control which theme is currently active on your WordPress website.
- template – the “Theme Name” as defined in style.css
- stylesheet – the actual name of your theme folder
- current_theme -the actual name of your theme folder
CREATE A BACKUP OF YOUR DATABASE BEFORE YOU BEGIN!
This tutorial on how to manually change WordPress theme to default assumes that the prefix of your database is wp_. If it isn’t, make sure to change the code presented below to match.
SQL to Find WordPress Theme Settings
First, run this to see what the current theme is set in your WordPress website.
SELECT * FROM wp_options WHERE option_name = 'template' OR option_name = 'stylesheet' OR option_name = 'current_theme';
Copy this information to somewhere safe. This is so you can quickly revert or change it later if you would like to.
SQL to Change Theme to Default in WordPress
Make sure that you have the default theme for WordPress loaded into /wp-content/themes/. For this example I am using the Twenty Fifteen WordPress default theme.
This works with ANY theme. Just make sure the theme files are loaded into your website.
Run the following code. Change ‘twentyfifteen’ to whatever WordPress theme you are using if not Twenty Fifteen.
UPDATE wp_options SET option_value = 'twentyfifteen' WHERE option_name = 'template'; UPDATE wp_options SET option_value = 'twentyfifteen' WHERE option_name = 'stylesheet'; UPDATE wp_options SET option_value = 'twentyfifteen' WHERE option_name = 'current_theme';
Problems Changing WordPress Theme Default Manually
The most common problems are:
- Typo in SQL
- Missing Theme Files
- Cached Page – Purge or Disable Cache
Please let me know if I missed anything or if you have additional tips.
This is a really handy fast trick to use to fix a WordPress website that you cannot access normally. Manually changing WordPress theme to default in the database is a fast and great way to test out and debug your website.