Home » Interview Question » How to Change WordPress Themes From the Database

How to Change WordPress Themes From the Database

How to Change WordPress Themes From the Database

Sometimes it becomes necessary to manually change your theme directly from the database instead of via the WordPress admin. This is actually what we use when upgrading our admin demos since it’s much faster using the command prompt or phpMyAdmin

Some times when we change or install new theme in our WordPress site or blog. We are getting error and our site is down due to new themes installation. if we change current selected theme to any other theme then our site is working. at this situation we don’t access our front end and back end. So we have only one method to change active theme from database.

To change current active theme There are three option_name in the database that need to be changed. That is control which theme is currently active on your website.

template The Theme Name as defined in style.css
stylesheet Name of your styleSheet, which is same as theme name
current_theme Name of your theme folder

Step 1: To change the above required details or column value we need to write a SQL query. Access your site database from PhpMyAdmin or command base and write a query.

change_theme1

Change the table prefix which are using in your database setting. like we are using wp_tablename

when we run above query in in PhpMyaAdmin we are getting there record as a response data from execution of the sql query. Below is the response data image.

Step 2: Now we update thse record from over new theme which we want to use(priviously working). Like we are change from the wordpress default theme “twentyfifteen”.

UPDATE wp_options SET option_value = ‘twentyfifteen’ WHERE option_name = ‘template';
UPDATE wp_options SET option_value = ‘twentyfifteen’ WHERE option_name = ‘stylesheet';
UPDATE wp_options SET option_value = ‘twentyfifteen’ WHERE option_name = ‘current_theme';

change wordpress theme from database

Step 3: After update thse three record now access your website and refresh(ctr F5) the url. you can see your site is working with “twentyfifteen” theme and you have changed your theme from database.

, , , , ,

Leave a Reply

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

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