Title: wp_get_global_styles_custom_css
Published: March 29, 2023
Last modified: May 20, 2026

---

# wp_get_global_styles_custom_css(): string

## In this article

 * [Return](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#wp--skip-link--target)

This function has been deprecated since 6.7.0. Use {@see ‘wp_get_global_stylesheet’}
instead for top-level custom CSS, or {@see ‘WP_Theme_JSON::get_styles_for_block’}
for block-level custom CSS.

Gets the global styles custom CSS from theme.json.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#return)󠁿

 string The global styles custom CSS.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#source)󠁿

    ```php
    function wp_get_global_styles_custom_css() {
    	_deprecated_function( __FUNCTION__, '6.7.0', 'wp_get_global_stylesheet' );
    	if ( ! wp_theme_has_theme_json() ) {
    		return '';
    	}
    	/*
    	 * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme
    	 * developer's workflow.
    	 */
    	$can_use_cached = ! wp_is_development_mode( 'theme' );

    	/*
    	 * By using the 'theme_json' group, this data is marked to be non-persistent across requests.
    	 * @see `wp_cache_add_non_persistent_groups()`.
    	 *
    	 * The rationale for this is to make sure derived data from theme.json
    	 * is always fresh from the potential modifications done via hooks
    	 * that can use dynamic data (modify the stylesheet depending on some option,
    	 * settings depending on user permissions, etc.).
    	 * See some of the existing hooks to modify theme.json behavior:
    	 * @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/
    	 *
    	 * A different alternative considered was to invalidate the cache upon certain
    	 * events such as options add/update/delete, user meta, etc.
    	 * It was judged not enough, hence this approach.
    	 * @see https://github.com/WordPress/gutenberg/pull/45372
    	 */
    	$cache_key   = 'wp_get_global_styles_custom_css';
    	$cache_group = 'theme_json';
    	if ( $can_use_cached ) {
    		$cached = wp_cache_get( $cache_key, $cache_group );
    		if ( $cached ) {
    			return $cached;
    		}
    	}

    	$tree       = WP_Theme_JSON_Resolver::get_merged_data();
    	$stylesheet = $tree->get_custom_css();

    	if ( $can_use_cached ) {
    		wp_cache_set( $cache_key, $stylesheet, $cache_group );
    	}

    	return $stylesheet;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/deprecated.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/deprecated.php#L6318)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/deprecated.php#L6318-L6362)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_is_development_mode()](https://developer.wordpress.org/reference/functions/wp_is_development_mode/)`wp-includes/load.php` |

Checks whether the site is in the given development mode.

  | 
| [wp_theme_has_theme_json()](https://developer.wordpress.org/reference/functions/wp_theme_has_theme_json/)`wp-includes/global-styles-and-settings.php` |

Checks whether a theme or its parent has a theme.json file.

  | 
| [WP_Theme_JSON_Resolver::get_merged_data()](https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_merged_data/)`wp-includes/class-wp-theme-json-resolver.php` |

Returns the data merged from multiple origins.

  | 
| [wp_cache_set()](https://developer.wordpress.org/reference/functions/wp_cache_set/)`wp-includes/cache.php` |

Saves the data to the cache.

  | 
| [wp_cache_get()](https://developer.wordpress.org/reference/functions/wp_cache_get/)`wp-includes/cache.php` |

Retrieves the cache contents from the cache by key and group.

  | 
| [_deprecated_function()](https://developer.wordpress.org/reference/functions/_deprecated_function/)`wp-includes/functions.php` |

Marks a function as deprecated and inform when it has been used.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#)

| Used by | Description | 
| [wp_enqueue_global_styles_custom_css()](https://developer.wordpress.org/reference/functions/wp_enqueue_global_styles_custom_css/)`wp-includes/deprecated.php` |

Enqueues the global styles custom css defined via theme.json.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_get_global_styles_custom_css/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.7.0](https://developer.wordpress.org/reference/since/6.7.0/) | Deprecated. Use ['wp_get_global_stylesheet'](https://developer.wordpress.org/reference/hooks/wp_get_global_stylesheet/) instead for top-level custom CSS, or ['WP_Theme_JSON::get_styles_for_block'](https://developer.wordpress.org/reference/classes/'WP_Theme_JSON/get_styles_for_block'/) for block-level custom CSS. | 
| [6.2.0](https://developer.wordpress.org/reference/since/6.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_global_styles_custom_css%2F)
before being able to contribute a note or feedback.