Sometimes a WordPress website may become inaccessible due to a theme error, plugin conflict, or a broken update. When this happens, you might not be able to log in to the admin dashboard to switch the theme normally. In such situations, accessing the database directly becomes a useful solution. By editing specific values inside the database, you can activate a different theme and restore your website’s functionality.
WordPress stores important configuration details in database tables, including the information that determines which theme is currently active. With the help of tools like phpMyAdmin, you can manually update these values and load another theme without needing dashboard access. This method is particularly helpful when troubleshooting theme-related issues that prevent the site from loading correctly.
This guide explains how to change WordPress theme in database safely using a clear step-by-step process. By following the instructions carefully and creating a backup beforehand, you can update the theme settings while avoiding potential data loss or configuration problems.
When to Change Theme via Database
You may need to change WordPress theme in database when the normal method of switching themes from the admin dashboard is not possible. This method is typically used for troubleshoot WordPress errors, especially when a faulty theme, plugin conflict, or update issue prevents access to your website. By modifying the theme settings directly in the database, you can quickly restore site functionality and regain dashboard access.
Here are some common situations where this method becomes useful:
- When the WordPress Dashboard Is Not Accessible: If a theme causes a fatal error or login issue, you may not be able to access the admin panel of WordPress. Editing the database allows you to activate another theme.
- After Installing a Faulty Theme: Sometimes a newly installed theme may contain coding errors or compatibility problems that break the site layout or functionality.
- When a Theme Update Breaks the Website: Updating a theme can occasionally introduce conflicts with plugins or the WordPress version, causing the site to stop loading correctly.
- If the Theme Folder Is Missing or Deleted: If the active theme folder is accidentally removed from the themes directory, WordPress cannot load it and the site may show errors.
- While Troubleshooting Theme Conflicts: Developers often switch themes through the database to quickly identify whether a theme is causing website errors or performance issues.
Important Things to Check Before Changing the Theme
Before you proceed to change WordPress theme in database, review the following points to prevent errors and ensure the process works smoothly:
- Confirm the Theme Is Uploaded: Check that the theme you want to activate is already uploaded to the wp-content → themes directory on your server. If the theme folder is missing, WordPress will not be able to load it.
- Verify the Theme Folder Name: The folder name you enter in the database must exactly match the theme folder name in the themes directory. Even a small spelling difference can prevent the theme from loading.
- Create a Database Backup: Always download a backup of your database before editing any tables. This allows you to restore your website quickly if something goes wrong while trying to change WordPress theme in database.
- Ensure the Theme Files Are Complete: Make sure the theme was uploaded properly and contains all required files such as style.css and functions.php. Incomplete theme files may cause errors.
- Check Theme Compatibility: Verify that the theme works properly with your current version of WordPress. Using an outdated theme may lead to design issues or functionality problems.
- Clear Website or Browser Cache: If your site uses caching plugins or server-level caching, clear the cache after changing the theme so the updated design loads correctly. Using the best WordPress cache plugins helps ensure that new theme changes appear instantly and improves overall website performance and loading speed.
Change WordPress Theme in Database ( Step-by-Step Guide )
The steps below will help you change WordPress theme in database and activate another theme.
Step 1: Backup Your WordPress Database Before Making Changes
Before modifying any settings inside the database, creating a backup should always be your first step. A backup ensures that if anything goes wrong during the process, you can restore the previous state of your website without losing important data. Most hosting providers allow you to create a quick backup directly from the database management tool.

Log in to your hosting account and open the control panel. From there, go to Databases → phpMyAdmin. The interface of phpMyAdmin will display all the databases associated with your hosting account. Select the database used by your WordPress website from the left sidebar.
Once the database opens, look at the top menu and click the Export tab. Choose the Quick Export option and download the SQL file to your computer. This file contains all database tables and settings for your site and serves as a safety backup before making any changes. Creating this backup is especially important when fixing php errors in wordpress, as it allows you to restore your website quickly if anything goes wrong during troubleshooting.
Creating this backup is important before you attempt to change WordPress theme in database, because the process involves editing configuration values that control how the site loads. Having a backup gives you a safety net if any incorrect changes occur.
Step 2: Open phpMyAdmin from Your Hosting Dashboard

To edit WordPress settings directly, you must access the database through your hosting panel. Start by logging in to your hosting account and opening the main control dashboard provided by your hosting service. Many hosting providers use cPanel, although the layout may differ slightly depending on the company. Choosing the best web hosting for WordPress ensures you get easy database access, reliable performance, and user-friendly control panels that simplify website management tasks.
Inside the dashboard, scroll until you find the Databases section. Within this section, locate and click the phpMyAdmin icon. This tool opens in a new tab and allows you to view and modify all database tables connected to your website.
After phpMyAdmin loads, you will see a list of databases in the left sidebar. Each database usually represents a different website or application hosted on your account. This interface is where you will locate the database tables that store WordPress settings.
Accessing phpMyAdmin is a necessary step when you need to change WordPress theme in database, particularly when the WordPress admin dashboard cannot be accessed due to a theme error or compatibility issue.
Step 3: Identify and Select the Correct Website Database
When phpMyAdmin opens, the left sidebar will display several database names. If your hosting account manages more than one website, multiple databases may appear in this list. Selecting the correct database is important before making any changes.

To confirm which database belongs to your website, open the hosting File Manager and navigate to the WordPress installation folder. Locate the wp-config.php file and open it. Inside this file you will find a line that defines the database name used by your website.
Return to phpMyAdmin and click on that specific database name in the sidebar. The screen will now display all the tables created by WordPress, including tables for posts, users, comments, and settings.
Choosing the correct database ensures that the edits you perform will apply only to the intended website. This step is essential before you proceed further to change WordPress theme in database, as modifying the wrong database could affect another website hosted on the same account.
Step 4: Navigate to the Options Table That Stores Site Settings
After selecting the correct database, you will see a list of tables displayed in the main panel. WordPress typically creates tables with the prefix wp_, followed by their function. The table you need to access is the one that stores general website settings.
Look for the table named wp_options in the list. Some installations use a custom prefix for security reasons, so the table might appear as something like xyz_options. Regardless of the prefix, the table name will always end with _options.
Click on this table to open it. Once opened, you will see a list of rows containing columns such as option_id, option_name, and option_value. These rows store configuration values that control various aspects of the website.
This table includes the entries that determine which theme is currently active. Accessing it allows you to manually change WordPress theme in database by editing the stored theme configuration values directly within the database.
Step 5: Search for the Template and Stylesheet Records
Inside the options table, there will be many configuration entries, so locating the correct ones is important. At the top of the phpMyAdmin interface, click the Search tab to quickly find specific records.
In the search field, type template and run the search. This will display the row where the option_name column is set to template. The value stored in the option_value column represents the active theme’s main folder name.
Next, repeat the search for stylesheet. This row contains the theme directory responsible for loading the design styles of the active theme. In most cases, the template and stylesheet values are identical because they reference the same theme folder.
Finding these two entries is a key step before editing the theme settings. These database records are the exact values WordPress reads when loading your website, which is why modifying them allows you to change WordPress theme in database even if the dashboard is inaccessible.
Step 6: Edit the Theme Folder Name in Both Entries
Once you locate the template and stylesheet rows, the next step is modifying their values. Click the Edit button next to the template row. A form will open allowing you to update the option_value field.
Replace the existing value with the folder name of the theme you want to activate. The folder name must match exactly with the directory located inside wp-content → themes in your website files. For example, if the theme folder is named astra, you should enter that same name in the option_value field.
Click Go or Save to apply the change. After updating the template row, repeat the same process for the stylesheet row so that both entries contain the same theme folder name.
This editing process is the main action required to change WordPress theme in database, because WordPress reads these values to determine which theme files should be loaded when the website is accessed.
Step 7: Refresh the Website and Confirm the Theme Update
After saving the updated values in the options table, the final step is verifying that the theme change worked correctly. Open your website in a new browser tab and refresh the page to see if the design has changed to the selected theme.
If the website loads with the new layout, the update was successful. In some cases, cached files may prevent the change from appearing immediately. Clearing your browser cache or refreshing the page in a private browsing window can help display the updated theme.

You should also log in to your WordPress dashboard if it becomes accessible again. Navigate to Appearance → Themes to confirm that the new theme is marked as active.
Completing this verification step confirms that the process used to change WordPress theme in database worked correctly and that the website is now running with the intended theme configuration.
Wrapping Up
Changing a theme directly through the database is not something most users need to do regularly, but it becomes extremely useful when the WordPress dashboard is unavailable. By accessing phpMyAdmin and editing the correct records in the options table, you can quickly activate a different theme and restore access to your website. The key steps involve backing up the database, identifying the correct database tables, and updating the template and stylesheet values with the correct theme folder name.
It is always important to double-check the theme folder name and ensure the theme files exist in the correct directory before making any changes. Clearing your browser or website cache after the update can also help ensure the new design loads properly.
Once the process is completed successfully, your website should load using the selected theme and the admin dashboard should become accessible again. Following these steps carefully will help you safely change the WordPress theme in database whenever a theme issue prevents normal theme switching.
FAQs
1. Why would I need to change the WordPress theme from the database?
You may need to do this when the WordPress dashboard is not accessible due to a broken theme, plugin conflict, or error. Changing it in the database helps restore access.
2. Is it safe to change the WordPress theme through the database?
Yes, it is safe if done carefully. Always create a database backup before making any changes.
3. Which table stores the active theme in WordPress?
The active theme information is stored in the wp_options table. The template and stylesheet entries contain the active theme folder name.
4. What value should be entered in template and stylesheet?
Enter the exact theme folder name from the wp-content/themes directory. The name must match perfectly.
5. Will changing the theme affect my website content?
No, it will not affect posts, pages, or media. It only changes the design and layout of the website.
6. What if the new theme does not load after updating the database?
Check the theme folder name, confirm the theme files exist, and clear your website or browser cache.







