How to change wordpress themes from backend?
Introduction
There are situations where you may not be able to access the WordPress admin dashboard due to forgotten credentials, plugin conflicts, a broken dashboard, or other issues.
In such cases, you can change the active WordPress theme directly from the backend by updating the theme settings in the WordPress database.
This method is useful when you have server or database access but cannot access Appearance → Themes from the WordPress dashboard.
Prerequisites
Before proceeding, make sure you have:
- WordPress installation.
- SSH access to the server.
- MySQL/MariaDB command-line access, if using the database CLI.
- Access to the WordPress database.
- The theme we want to activate is already installed under:
wp-content/themes/
Important: Take a database backup before making any changes to the WordPress database.
Implementation
Step 1: Access the WordPress Database
Log in to the server using SSH, open phpMyAdmin, or access the MySQL/MariaDB command line.
For MySQL/MariaDB CLI, connect to the WordPress database:
USE wordpress_database;
Replace wordpress_database with your actual WordPress database name.
Step 2: Verify the Theme
Before activating a theme from the database, make sure the corresponding theme directory exists:
ls -la /path/to/wordpress/wp-content/themes/
For this example, we will activate the twentysixteen theme.
The directory should be:
wp-content/themes/twentysixteen/
Step 3: Update the WordPress Theme
WordPress stores theme-related settings in the wp_options table.\
Run the following queries:
UPDATE wp_options SET option_value = 'twentysixteen' WHERE option_name = 'template'; UPDATE wp_options SET option_value = 'twentysixteen' WHERE option_name = 'stylesheet'; UPDATE wp_options SET option_value = 'twentysixteen' WHERE option_name = 'current_theme';
As mentioned above, replace the appropriate theme name in case we meant a different theme.
Step 4: Verify the Changes
You can verify the current theme values using:
SELECT option_name, option_value
FROM wp_options
WHERE option_name IN ('template', 'stylesheet', 'current_theme');
How It Works
WordPress Website
|
v
WordPress Database
|
v
wp_options Table
|
v
Update theme settings
|
v
template / stylesheet / current_theme
|
v
WordPress loads the selected theme
|
v
New theme displayed on the website
Conclusion
Changing a WordPress theme from the backend is a useful recovery method when the WordPress admin dashboard is inaccessible.
By updating the theme-related values in the wp_options table, you can switch the active theme without accessing the WordPress dashboard.
