Using WordPress ‘get_locale_stylesheet_uri()’ PHP function

The get_locale_stylesheet_uri() WordPress PHP function retrieves the localized stylesheet URI.

Usage

$localized_stylesheet = get_locale_stylesheet_uri();

Parameters

  • None

More information

See WordPress Developer Resources: get_locale_stylesheet_uri

Examples

Load a localized stylesheet

// Get the localized stylesheet URI
$localized_stylesheet = get_locale_stylesheet_uri();

// Enqueue the localized stylesheet
wp_enqueue_style('localized-stylesheet', $localized_stylesheet);

Change the stylesheet directory URI

add_filter('stylesheet_directory_uri', 'my_custom_stylesheet_directory_uri');

function my_custom_stylesheet_directory_uri($stylesheet_uri) {
    return $stylesheet_uri . '/my-custom-folder';
}

Change the locale stylesheet URI

add_filter('locale_stylesheet_uri', 'my_custom_locale_stylesheet_uri', 10, 1);

function my_custom_locale_stylesheet_uri($locale_stylesheet_uri) {
    return $locale_stylesheet_uri . '/my-custom-folder';
}

Load a localized stylesheet with a custom handle

$localized_stylesheet = get_locale_stylesheet_uri();
wp_enqueue_style('my-custom-handle', $localized_stylesheet);

Load a localized stylesheet with media type

$localized_stylesheet = get_locale_stylesheet_uri();
wp_enqueue_style('localized-stylesheet', $localized_stylesheet, array(), false, 'all');