HOWTO change a theme slug in WordPress

If you rename a WordPress theme, you will lose customizations (theme mods). They’re stored in wp_options based on the theme’s slug.

WP CLI makes it easy to quickly copy the theme options over:

wp> $new_slug = "my-new-theme-slug";
wp> $theme_slug = get_option( 'stylesheet' )
wp> $mods       = get_option( "theme_mods_$theme_slug" );
wp> update_option( "theme_mods_$new_slug", $mods );

Leave a comment

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