Manually restoring a WordPress theme after a crash

WordPress is a great blog engine, used by millions of people around the globe, and one of the best things (and probably also one of the main reasons for its success) is an easy to use and huge database of plugins and themes. With just some clicks, you can change the theme or install a cool new plugin to enhance your blog.

However, sometimes not everything works well, and you may end with a non-working blog if you installed a problematic (or old) theme. You see, my girlfriend loooooves themes, so much that she tries a new one every day. But sometimes one of those themes doesn’t work, thus trashing hers blog, including the admin area.

There is a way to manually fix it, but you will need access to the database (be it via a terminal, or something like phpmyadmin). Open the database where wordpress in installed in, and find the values you’ll have to change:


select * from wp_options where option_name like '%current%' or option_name = 'template' or option_name = 'stylesheet';

It should return something like this:

+-----------+---------+---------------+--------------+----------+
| option_id | blog_id | option_name   | option_value | autoload |
+-----------+---------+---------------+--------------+----------+
|        45 |       0 | template      | Ledgy        | yes      |
|        46 |       0 | stylesheet    | Ledgy        | yes      |
|      5810 |       0 | current_theme | Ledgy        | yes      |
+-----------+---------+---------------+--------------+----------+

In this case, “Ledgy” is my problematic theme, and I want to change to another one that I know that works (like the Default theme, or the previous one, if you remember the name). In order to find the available themes you have, go to the wp-content/themes of your wordpress installation. Each of the directories there represents the theme’s name you’ll use to update the options table. In my case, I know that the “SP142″ works fine. 

In order to update the table, execute the following statement:

update wp_options set option_value = 'SP142' where option_id in (45, 46, 5810);

Just make sure to use the correct IDs, and you are done!

Leave a Reply

Your email address will not be published. Required fields are marked *

*


three * 8 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>