Back to knowledgebase

Change a WordPress Theme in the Database

If a broken WordPress theme stops you from accessing the WordPress dashboard, you can change the active theme directly in the database.

This should only be used as a recovery method. If you can still access WordPress, change the theme from Appearance > Themes instead.

Before you start, take a database backup.

  1. Open phpMyAdmin from your hosting control panel.
  2. Select the database used by your WordPress site.
  3. Open the table ending in _options.
  4. Find the rows named template and stylesheet.
  5. Edit the option_value for template.
  6. Enter the folder name of an installed theme.
  7. Save the change.
  8. Edit the option_value for stylesheet.
  9. Enter the same theme folder name, unless you are activating a child theme.
  10. Save the change.

The theme name must match a folder that already exists in /wp-content/themes/. For recovery, it is usually best to switch to a default WordPress theme that is already installed.

The database table prefix may not be wp_. If your site uses a custom table prefix, look for the table that ends in _options.

After saving the change, reload your website and try to log in to WordPress again.