{"id":2427,"date":"2014-02-17T16:20:35","date_gmt":"2014-02-17T16:20:35","guid":{"rendered":"http:\/\/blog.shineservers.com\/?p=2427"},"modified":"2014-02-17T16:20:35","modified_gmt":"2014-02-17T16:20:35","slug":"change-wordpress-themes-directly-database","status":"publish","type":"post","link":"https:\/\/www.shineservers.com\/2014\/02\/17\/change-wordpress-themes-directly-database\/","title":{"rendered":"How to Change WordPress Themes Directly From the Database"},"content":{"rendered":"<p>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\u2019s much faster using the command prompt or phpMyAdmin.<\/p>\n<h2>Prerequisites<\/h2>\n<ol>\n<li>Comfortable with either phpMyAdmin or command prompt to run SQL statements<\/li>\n<li>Some understanding of WordPress option values<\/li>\n<\/ol>\n<h3>Getting Started<\/h3>\n<p>There are three\u00a0<code>option_name<\/code>\u00a0rows in the database that need to be changed. These are what control which theme is currently active on your website.<\/p>\n<ul>\n<li>template\u00a0\u2013 the \u201cTheme Name\u201d as defined in style.css<\/li>\n<li>stylesheet\u00a0\u2013 the actual name of your theme folder<\/li>\n<li>current_theme\u00a0-the actual name of your theme folder<\/li>\n<\/ul>\n<h3>Step 1<\/h3>\n<p>First let\u2019s do a quick check and see what theme you currently have set. Note, this SQL assumes you have your tables named with the standard\u00a0<code>wp_<\/code>\u00a0prefix. If that is not the case, you\u2019ll need to change<code>wp_options<\/code>\u00a0to whatever prefix your table structure uses.<\/p>\n<div>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>SELECT *\nFROM wp_options\nWHERE option_name = 'template'\nOR option_name = 'stylesheet'\nOR option_name = 'current_theme';<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>After running the SQL from within phpMyAdmin, you should see something like this:<\/p>\n<p><a href=\"http:\/\/docs.appthemes.com\/files\/2011\/07\/wordpress-change-theme-database.png\" rel=\"colorbox\"><img fetchpriority=\"high\" decoding=\"async\" title=\"wordpress-change-theme-database\" alt=\"wordpress-change-theme-database\" src=\"http:\/\/docs.appthemes.com\/files\/2011\/07\/wordpress-change-theme-database-300x209.png\" width=\"300\" height=\"209\" \/><\/a><\/p>\n<p>Results after selecting the three option rows.<\/p>\n<h3>Step 2<\/h3>\n<p>Now it\u2019s time to change the theme. Figure out which one you\u2019d like to switch to and change the three<code>option_values = ''<\/code>\u00a0\u00a0below. You\u2019ll notice that the first option is capitalized which is important.<\/p>\n<p>Once you\u2019ve got your SQL code you\u2019ll run it to change your current theme. (this example assumes you have ClassiPress already in\u00a0<code>\/wp-content\/themes\/classipress\/<\/code>.<\/p>\n<div>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>UPDATE wp_options SET option_value = 'ClassiPress' WHERE option_name = 'template';\nUPDATE wp_options SET option_value = 'classipress' WHERE option_name = 'stylesheet';\nUPDATE wp_options SET option_value = 'classipress' WHERE option_name = 'current_theme';<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>After running that SQL from within phpMyAdmin, you should see a success message similar to this:<\/p>\n<p><a href=\"http:\/\/docs.appthemes.com\/files\/2011\/07\/wordpress-change-theme-database-done.png\" rel=\"colorbox\"><img decoding=\"async\" title=\"wordpress-change-theme-database-done\" alt=\"wordpress-change-theme-database-done\" src=\"http:\/\/docs.appthemes.com\/files\/2011\/07\/wordpress-change-theme-database-done-300x126.png\" width=\"300\" height=\"126\" \/><\/a><\/p>\n<p>If your SQL statements were correctly run, you&#8217;ll see a message like this:<\/p>\n<h3>Step 3<\/h3>\n<p>Go back to your website and refresh. You should now see the new theme running.<\/p>\n<h3>Having Trouble?<\/h3>\n<p>If you get an error 500 page or a different error, it\u2019s likely you didn\u2019t use the correct values for the theme. Go back and make sure they are correct.<\/p>\n<p>One common error occurs when you\u2019ve got the same theme but with different folder names (i.e. classipress-31 and classipress-312). In this situation the \u201cTheme Name\u201d in style.css is the exact same so your \u201ctemplate\u201d option_name should be \u201cClassiPress\/classipress-312\u2033 instead of just \u201cClassiPress\u201d.<\/p>\n<p>If it\u2019s still showing the old theme, clear your cache (if you use a caching plugin like WP Super Cache) and that should resolve it.<\/p>\n<h3>Get Out of Jail Free Card<\/h3>\n<p>If you\u2019re in a bind and can\u2019t get anything to work, just run this SQL from phpMyAdmin. It will reset your website to use the default Twenty Eleven theme (change your\u00a0<code>wp_<\/code>\u00a0prefix if necessary).<\/p>\n<div>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>UPDATE wp_options SET option_value = 'Twenty Eleven' WHERE option_name = 'template';\nUPDATE wp_options SET option_value = 'twentyeleven' WHERE option_name = 'stylesheet';\nUPDATE wp_options SET option_value = 'twentyeleven' WHERE option_name = 'current_theme';<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019s much faster using the command prompt or phpMyAdmin. Prerequisites Comfortable with either phpMyAdmin or command prompt to run SQL statements Some understanding of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[107],"tags":[164],"class_list":["post-2427","post","type-post","status-publish","format-standard","hentry","category-wordpress-2","tag-how-to-change-wordpress-theme-directly-from-database"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/2427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/comments?post=2427"}],"version-history":[{"count":0,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/2427\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/media?parent=2427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/categories?post=2427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/tags?post=2427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}