Uploaded a customized WordPress Theme, Logged in to Wp-Admin, change the current theme to the new theme, boom! All front end and backend is now error 5XX.
Does it sounds familiar to you? It happens quite a lot of time on me when I try to migrate my site to a new server and trying to test the old theme on the new server with a fresh WordPress setup.
It happens when your customized theme was using some plugins such as Advance Custom Fields and the plugin actually not yet installed on your new WordPress.
When you can no longer access to wp-admin, the only way to undo this is changing your theme in the database.
- Log in to your database using phpmyadmin, mysql workbench or just ssh to your database server;
- Change the “template” value in your “wp_options” table. By default the option table is called “wp_options” but the table name prefix can be different depends on how you setup your WordPress.
preview current setting:
SELECT * from wp_options WHERE option_name = 'template'
Update the table and change the theme to some default theme say “twentysixteen”:UPDATE wp_options SET option_value = 'twentysixteen' WHERE option_name = 'template';
- Do the same for ‘stylesheet’:
UPDATE wp_options SET option_value = 'twentysixteen' WHERE option_name = 'stylesheet';
- You’ve successfully undo switching a theme that breaks your WordPress.
Learn more: Optimize your WordPress for Better Performance and Security