Adding customizer styles with wp_add_inline_style

You can try to detect if the current used theme is a child and if so pointing the inline CSS to the right style. I didn’t tested this solution but could be a good starting point.

function mytheme_enqueue_style()
{
    wp_enqueue_style( 'parent-theme-style',get_template_directory_uri() . '/style.css', false );

    if(is_child_theme())
    {
        wp_enqueue_style( 'child-theme-style', get_stylesheet_directory_uri() . '/style.css', array('parent-theme-style')  );
    }

    $style = get_theme_mod ('all-mods');
    $where = is_child_theme() ? 'child-theme-style' : 'parent-theme-style';
    wp_add_inline_style( $where, $style );
}

add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_style' );

NOTE

There is a difference between get_template_directory_uri() and get_stylesheet_directory_uri() in fact on codex we have

In the event a child theme is being used, this function will return
the child’s theme directory URI. Use get_template_directory_uri() to
avoid being overridden by a child theme.

Leave a Comment