DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk9 min

How to Change Your WordPress Theme From the Database (Safely)

A careful guide to changing WordPress’s template and stylesheet options in the database, with phpMyAdmin steps, SQL examples, child-theme rules, testing and recovery advice.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If you cannot reach wp-admin, you can activate an installed WordPress theme by editing two rows in the database. Back up the database first, open the database used by the site, find its options table (usually ending in _options), and set the template and stylesheet options to the target theme’s directory slug. Confirm that the theme folder exists in wp-content/themes before saving.

What changing the theme in the database actually does

WordPress stores the active theme as two options in the site’s options table:

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • template identifies the parent theme directory.
  • stylesheet identifies the stylesheet theme directory.

For a standard theme without a child theme, both values are normally the same directory slug. For a child theme, stylesheet is the child directory and template is the parent directory. WordPress core’s switch_theme() function updates these options and performs additional theme-switch bookkeeping when a normal switch is made through WordPress.

A database edit changes which theme WordPress tries to load; it does not upload, repair or install theme files. The selected directory must already exist under wp-content/themes. A display name such as “Twenty Twenty-Four” is not necessarily the correct value. The database needs the directory slug, for example twentytwentyfour, exactly as it appears on the server.

When a database switch is appropriate

Use this method when the public site or login is broken because of a theme or plugin error and you cannot reach the dashboard. It is an emergency activation method, not a replacement for the normal Appearance-to-Themes workflow.

Good reasons to use it

  • A fatal error prevents wp-admin from loading.
  • A recently activated theme causes a blank page or repeated server error.
  • You need to switch to a known-good installed theme before troubleshooting further.
  • Hosting support has given you database access but the dashboard is unavailable.

When to use another method first

If WordPress Recovery Mode is available, use the recovery link sent by WordPress before editing the database. Recovery Mode was introduced in WordPress 5.2 and can sometimes let you regain access after a fatal error without FTP or direct code editing. Once you can log in, switching from the dashboard is safer because WordPress runs its normal theme-switch routines.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before editing: safety checks

Make a complete database backup

Export the entire WordPress database and retain the original file before changing anything. A database export gives you a way to restore the old option values if the site remains broken or another row is accidentally changed. Do not rely on an automatically generated backup unless you know when it was made and how to restore it.

Record the current values

Write down the existing values of template and stylesheet before editing. If the new theme fails, restoring those two values is the quickest rollback when the old theme files are still present.

Confirm the target theme files

Use your host’s file manager, SFTP, FTP or support channel to verify the exact directory name under wp-content/themes. Check that the directory contains a valid theme, including a stylesheet with a WordPress theme header. Do not point the database at a folder that was deleted, renamed or only partially uploaded.

Expect a maintenance window

Visitors may see an error, an unstyled page or a partially rendered page while caches update. If the site receives important traffic, make the change during a quiet period and keep a second browser window ready for testing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Find the correct WordPress database and options table

  1. Open the site’s WordPress configuration file, usually wp-config.php, through the host’s file manager or a secure file connection.
  2. Read the DB_NAME value. That is the database you need to select in your database client.
  3. Read $table_prefix. The default prefix is wp_, but many installations use a custom prefix for security or because several sites share a database.
  4. In the selected database, open the table whose name ends in _options. With the default prefix it is wp_options; with a custom prefix it may look like site7_options.

Do not assume that the first database listed by your host is the right one, and do not assume that the table is named exactly wp_options. Using the wrong database or prefix changes nothing on the live site and can lead to editing an unrelated installation.

Method 1: change the values in phpMyAdmin

The labels vary slightly between phpMyAdmin versions and hosting panels, but the operation is the same.

  1. Open phpMyAdmin from your hosting control panel and select the database identified in wp-config.php.
  2. Open the table ending in _options.
  3. Use the table’s search or browse function to find rows where option_name is template and stylesheet.
  4. Choose Edit for the template row and replace only its option_value with the target parent theme’s directory slug.
  5. Edit the stylesheet row and replace only its option_value with the target stylesheet theme’s directory slug.
  6. Save each row, or save the submitted changes if your interface presents both edits together.
  7. Clear page and object caches, then open the public site and the login page in a private browser window.

For a normal theme, enter the same slug in both rows. For a child theme, enter the parent slug in template and the child slug in stylesheet. Preserve the spelling, capitalization and hyphens used by the actual directories; WordPress theme slugs are directory names, not marketing names.

Method 2: run SQL directly

A database client with an SQL tab can perform the same update. Replace wp_options with the real options-table name before running the statement.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
UPDATE wp_options
SET option_value = 'target-theme-slug'
WHERE option_name IN ('template', 'stylesheet');

This statement is suitable when both values should be identical. It updates only rows whose names are template or stylesheet; it does not install the theme or alter posts, pages or media.

Use separate statements for a child theme

When the parent and child slugs differ, update each row explicitly:

UPDATE wp_options
SET option_value = 'parent-theme-slug'
WHERE option_name = 'template';

UPDATE wp_options
SET option_value = 'child-theme-slug'
WHERE option_name = 'stylesheet';

Run a select query first if you want to verify the current rows and table prefix:

SELECT option_name, option_value
FROM wp_options
WHERE option_name IN ('template', 'stylesheet');

The result should show exactly two rows in the expected table. If it returns zero rows, stop and check the database, table prefix and option names rather than creating new rows.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to identify the right theme slug

The slug is the folder name, not necessarily the theme’s name shown in the WordPress interface. If the server contains:

wp-content/themes/
  twentytwentyfour/
  newsroom-child/
  newsroom/

then the standard Twenty Twenty-Four theme uses twentytwentyfour. The child theme uses stylesheet = newsroom-child and template = newsroom. A value such as Newsroom Child would be wrong unless that is literally the directory name.

Do not infer a slug from a zip filename. A zip can contain an extra top-level directory, and the extracted folder may have a different name. Verify the name on the server.

What to test immediately after saving

Open a private or uncached browser session so an old page does not make a failed switch look successful. Check the following in order:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Load the public homepage and at least one ordinary post or page.
  2. Open the login URL and sign in if it loads.
  3. Visit the dashboard and confirm that the active theme is the intended one.
  4. Open Appearance and inspect the theme screen, Customizer or Site Editor, depending on the theme.
  5. Check the primary menu, footer menu, widgets or block-based widget areas.
  6. Test a contact form, search, media attachment and any template used for key landing pages.
  7. Review the PHP error log and web-server error log for missing files, fatal errors or incompatible extensions.

Clear the page cache and object cache after the switch. A cached page can display the old design even though WordPress is using the new theme, while stale cached assets can make a working theme appear broken.

What changes and what does not

Changed by the database edit

  • The active parent and stylesheet theme pointers.
  • The theme WordPress attempts to load on the next request.

A direct row edit does not run every action that normally fires through the dashboard’s theme-switch process. WordPress core’s regular switch_theme() routine also performs switch-related bookkeeping.

Not automatically converted between themes

  • Theme-specific Customizer settings.
  • Widget assignments and widget-area definitions.
  • Menu locations and theme-specific menu presentation.
  • Block patterns, template parts and Site Editor settings.
  • Plugin settings or code that expects the previous theme.
  • Custom templates and CSS tied to the old theme.

WordPress stores much of this information, but a new theme may not declare the same locations or controls. Inspect the site rather than assuming the old layout will transfer cleanly.

Recovery when the new theme fails

Rollback using the recorded values

If the old theme directory still exists, edit template and stylesheet back to the values you recorded before the change. Clear caches and retest. This is why recording the original rows is as important as exporting the database.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a known-good installed theme

If the old theme itself is the cause of the outage, select another complete, compatible theme already present in wp-content/themes. Do not choose a directory that only contains a backup zip, a partially uploaded copy or a child theme whose parent is missing.

When database access is unavailable

Contact the hosting provider or administrator for access to the correct database. Some hosts provide phpMyAdmin; others can perform the two-row change for you after verifying ownership. Ask them to make a database backup and to confirm the exact database and table prefix before editing.

When the database points to a missing directory

The site can remain broken if either option names a nonexistent directory. Restore valid slugs or restore the missing theme files first. A database value cannot substitute for the files themselves.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choosing a recovery method

Method Dashboard required? Files required? Backup or rollback Best use
Normal theme switch in WordPress Yes Target theme installed Use a backup before major changes The safest routine change because WordPress runs its normal switch logic
Recovery Mode No ordinary dashboard access; recovery link required Existing theme or plugin files Follow the recovery screen and keep a database backup Fatal errors on WordPress 5.2 and later when Recovery Mode is offered
phpMyAdmin row edit No Target theme installed Export the database and record both old values Emergency activation when the dashboard is inaccessible
SQL query No Target theme installed Export the database; verify the table prefix Repeatable or scripted changes by an administrator
Hosting support No Depends on the requested theme Ask support to back up and document the change No direct database credentials or uncertain database mapping

The deciding factors are whether you can access the dashboard, whether Recovery Mode is available, whether a backup exists, and whether the target theme is installed and compatible. Database access is powerful but unforgiving: one wrong table or slug can leave the site unavailable.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common mistakes and fixes

Entering the display name instead of the folder slug

Symptom: WordPress reports a missing theme or shows a fatal error. Fix: inspect wp-content/themes and use the exact directory name in both relevant rows.

Editing the wrong options table

Symptom: the query succeeds but the live site does not change. Fix: recheck DB_NAME and $table_prefix in wp-config.php. Multisite or multiple installations may have several similarly named tables.

Using the same value for a child theme and its parent

Symptom: the child theme’s custom styles disappear or WordPress loads only the parent. Fix: set template to the parent directory and stylesheet to the child directory.

Changing only one of the two rows

Symptom: the site loads an unexpected theme or throws missing-file errors. Fix: verify both option values as a pair and correct them together.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Forgetting caches

Symptom: different browsers show different designs. Fix: purge page and object caches, then test in a private window and check the response after the cache has rebuilt.

Expecting the new theme to preserve every layout

Symptom: menus, widgets, headers or templates are absent. Fix: map menu locations, rebuild widget or block areas and review theme-specific settings after the site is stable.

A safe, repeatable checklist

  • Confirm why the dashboard is unavailable and try Recovery Mode if WordPress offers it.
  • Export the complete database.
  • Record the current template and stylesheet values.
  • Verify the target theme directory and, for a child theme, its parent directory.
  • Identify DB_NAME and the custom table prefix from wp-config.php.
  • Open the matching _options table.
  • Update both option rows, using separate values when parent and child slugs differ.
  • Confirm the saved values with a query or by reopening the rows.
  • Purge caches and test the homepage, posts, login, menus, widgets and key templates.
  • Keep the export and old values until the site has been stable and manually reviewed.

Final guidance

Changing template and stylesheet is the direct database-level way to point WordPress at another installed theme when normal administration is unavailable. The procedure is short, but the safeguards matter more than the SQL: back up first, use the real options table, enter directory slugs rather than display names, treat child themes as two different values, and verify that the files exist before saving. After the switch, clear caches and inspect the site’s menus, widgets, templates and theme settings because a database pointer change cannot recreate theme-specific configuration.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.