How to import theme mods when switching from a ThemeIsle Hestia child theme to Hestia

Add this piece of code in Hestia/Hestia PRO's functions.php file just at the end:

add_action( 'after_switch_theme', 'hestia_import_theme_mods_from_themeisle_child_themes' );

/**
 * Import theme mods when switching from a Themeisle Hestia child theme to Hestia
 */
function hestia_import_theme_mods_from_themeisle_child_themes() {

    // Get the name of the previously active theme.
    $previous_theme = strtolower( get_option( 'theme_switched' ) );

    if ( ! in_array( $previous_theme, array( 'christmas-hestia', 'tiny-hestia' ) ) ) {
        return;
    }

    // Get the theme mods from the previous theme.
    $previous_theme_content = get_option( 'theme_mods_' . $previous_theme );

    if ( ! empty( $previous_theme_content ) ) {
        foreach ( $previous_theme_content as $previous_theme_mod_k => $previous_theme_mod_v ) {
            set_theme_mod( $previous_theme_mod_k, $previous_theme_mod_v );
        }
    }
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us