Choosing Default WordPress Theme through database

There are times when there is problem in your theme that you have installed in your site and your site goes blank or white. In this situation you will not be able to log in to the WordPress Admin area. In this situation you can simply use the database to choose the default theme and solve the problem.

Step 1: It is highly recommended to backup your database before your work on any database command.

Step 2: Login to your database using phpMyAdmin (or whatever), Click on your database and click on the SQL tab and enter the following SQL query:
UPDATE wp_options SET option_value='default' WHERE option_name='template' OR option_name='stylesheet' LIMIT 2;
This query will change the wordpress theme to default.

10 Replies to “Choosing Default WordPress Theme through database”

  1. Finding good information from blogs is not always easy, but you have done a great job here, interesting title ( Choosing Default WordPress Theme through database | Sakin Shrestha > Management and IT Consultant (WordPress Expert) ) too, cool.

  2. Saved the day. Activated a child theme that then whipped things out. Deleted child theme, then parent theme, and still nothing. This worked wonders. Thanks a million!

  3. Very nice solution. I was’nt getting any solution before and I was going to drop the database finally. Thanks Sakin.

  4. Many Thanks for kind help. It was really helpful as my site was doWn after changing server and doing this I was able to login !!! Once again Many Thanks – Mukesh Vadodaria – INDIA

  5. Thank you. With a few tweaks (db prefix and changing the name of the template) I was able to restore my site. Exactly what I was looking for.

  6. Many thanks for sharing this, after moving my files and database over to a new server the theme somehow broke, but running this code get my website up again.

  7. Awesome script!! A couple of things to add. If you have a security plugin like I do that changes the table prefix then you will have to change the wp_options to whatever prefix is used in your db. in my case “wpfn_options”. And their is no theme called “default” that I know of. FTP to your site and look at the directory names under /wp-content/themes. Pick the directory name (which are theme names) that you want to be the theme you change to in the script. Use THAT name instead of “default”