wp-content » themes » Different Ways to Change active WordPress theme

Different Ways to Change active WordPress theme

Here are a few ways you can change the active theme in WordPress:

Using WP Dashboard

Using the WordPress Administration Screens: You can change the active theme by going to the “Appearance” -> “Themes” page in the WordPress Administration Screens and selecting a new theme.

image 10 1024x561 - Different Ways to Change active WordPress theme
Change WP Theme from wp-admin

Using functions.php or a custom plugin

Using the wp_set_theme function: You can use the wp_set_theme function to change the active theme. For example:

wp_set_theme('twentytwenty');  // change the active theme to the default theme (twentytwenty)

or in a form of a plugin:

<?php
/*
Plugin Name: Change Theme to Default Plugin
Description: This plugin changes the active theme to the default theme.
Version: 1.0
Author: Stefan Pejcic
*/

function change_theme_to_default_plugin_activate() {
  switch_theme('twentytwenty');  // change the active theme to the default theme (twentytwenty)
}
register_activation_hook(__FILE__, 'change_theme_to_default_plugin_activate');

From the PHPMyAdmin

Modifying the template and stylesheet options: You can change the active theme by modifying the template and stylesheet options in the wp_options table in the WordPress database. For example:

update_option('template', 'twentytwenty');
update_option('stylesheet', 'twentytwenty');
image 11 1024x658 - Different Ways to Change active WordPress theme
Change WP Theme from the database

From MySQL

To change the active theme using an SQL command, you can use the UPDATE statement to modify the template and stylesheet options in the wp_options table.

Here is the SQL command to change the active theme to the default theme (twentytwenty):

UPDATE wp_options SET option_value='twentytwenty' WHERE option_name='template' OR option_name='stylesheet';

This command will update the option_value of the template and stylesheet options to ‘twentytwenty’, which will change the active theme to the default theme.

See also  Change logo on WordPress login page without using any plugin

Using WP-CLI

To change the active theme using WP-CLI, you can use the theme activate command.

For example, to change the active theme to the default theme (twentytwenty), you can use the following command:

wp theme activate twentytwenty

This command will activate the twentytwenty theme.

You can also use the --network flag to activate a theme for all sites in a multisite network. For example:

wp theme activate twentytwenty --network

I hope this helps! Let me know if you have any other questions.

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended