Today before few hours ago.. I changed my wordpress theme and I had some error in my new theme. When I enabled the new theme, I got a error page with few written lines in php. I was unable to access my wordpress blog both from frontend and backend (admin panel) so I thought to access database and change the theme.
As you all know.. WordPress is totally running with database only.. It just bring whatever there in database.. when you can change theme from dashboard.. you can also directly do this from database.
This is useful when you have uploaded corrupted theme and activate it or your theme needs a file which it doesn’t have access.. at that time you need to change your theme to “default” then only you can use dashboard..
Generally it is recommended to user to change themes from wordpress dashboard only but if you apply the theme which makes your blog and admin page blank or fill with errors. OMG.. how to get rid? only way to do it from backend.
Smart way to got rid from corrupted theme is using FTP,back up and delete everything from your current corrupted theme and upload fresh working theme (like twentyeleven twentytweleve) with the same your set theme folder name 😉 well it’s just a trick try that way first if you don’t get your problem solved database is there.. 🙂
Open your phpmyAdmin console from your web hosting provider.
Backup your database just for safety purpose before performing following steps.
Login to your MySql query window and search for template,stylesheet or current_theme as option_value. You will have table named wp_options which contains values of your current theme. You can view it by following query.
SELECT * FROM wp_options WHERE option_name = 'template' OR option_name = 'stylesheet'
OR option_name = 'current_theme';
It may happen you have changes your default tabelname prefix at time of installation so check it and try to find yourprefix+_option table name from your phpmyAdmin. Now you can update those rows with default value instead of your theme.
UPDATE wp_options SET option_value = 'default' WHERE option_name = 'template';
UPDATE wp_options SET option_value = 'default' WHERE option_name = 'stylesheet';
UPDATE wp_options SET option_value = 'default' WHERE option_name = 'current_theme';
Now try to login to your Admin dashboard panel or access your site.. it should work.. if it doesn’t check the value of theme and reupload that theme folder using ftp to your server.
in expert way you can run in follwing style too
UPDATE wp_options SET option_value = 'default' WHERE option_name in ('template','stylesheet','current_theme')
Please leave comments so that I can come to know if anything is missing in above steps.