Title: wp_enqueue_stored_styles
Published: November 2, 2022
Last modified: February 24, 2026

---

# wp_enqueue_stored_styles( array $options = array() )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_enqueue_stored_styles/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_enqueue_stored_styles/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_enqueue_stored_styles/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_enqueue_stored_styles/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_enqueue_stored_styles/?output_format=md#changelog)

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

Fetches, processes and compiles stored core styles, then combines and renders them
to the page.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_enqueue_stored_styles/?output_format=md#description)󠁿

Styles are stored via the style engine API.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_enqueue_stored_styles/?output_format=md#parameters)󠁿

 `$options`arrayoptional

An array of options to pass to [wp_style_engine_get_stylesheet_from_context()](https://developer.wordpress.org/reference/functions/wp_style_engine_get_stylesheet_from_context/).

 * `optimize` bool
 * Whether to optimize the CSS output, e.g., combine rules.
    Default false.
 * `prettify` bool
 * Whether to add new lines and indents to output.
    Default to whether the `SCRIPT_DEBUG`
   constant is defined.

More Arguments from wp_style_engine_get_stylesheet_from_context( … $options )

An array of options.

 * `optimize` bool
 * Whether to optimize the CSS output, e.g. combine rules.
    Default false.
 * `prettify` bool
 * Whether to add new lines and indents to output.
    Defaults to whether the `SCRIPT_DEBUG`
   constant is defined.

Default:`array()`

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

    ```php
    function wp_enqueue_stored_styles( $options = array() ) {
    	// Note: Styles printed at wp_footer for classic themes may still end up in the head due to wp_load_classic_theme_block_styles_on_demand().
    	$is_block_theme   = wp_is_block_theme();
    	$is_classic_theme = ! $is_block_theme;

    	/*
    	 * For block themes, this function prints stored styles in the header.
    	 * For classic themes, in the footer.
    	 */
    	if (
    		( $is_block_theme && doing_action( 'wp_footer' ) ) ||
    		( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) )
    	) {
    		return;
    	}

    	$core_styles_keys         = array( 'block-supports' );
    	$compiled_core_stylesheet = '';
    	$style_tag_id             = 'core';
    	// Adds comment if code is prettified to identify core styles sections in debugging.
    	$should_prettify = isset( $options['prettify'] ) ? true === $options['prettify'] : defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
    	foreach ( $core_styles_keys as $style_key ) {
    		if ( $should_prettify ) {
    			$compiled_core_stylesheet .= "/**\n * Core styles: $style_key\n */\n";
    		}
    		// Chains core store ids to signify what the styles contain.
    		$style_tag_id             .= '-' . $style_key;
    		$compiled_core_stylesheet .= wp_style_engine_get_stylesheet_from_context( $style_key, $options );
    	}

    	// Combines Core styles.
    	if ( ! empty( $compiled_core_stylesheet ) ) {
    		wp_register_style( $style_tag_id, false );
    		wp_add_inline_style( $style_tag_id, $compiled_core_stylesheet );
    		wp_enqueue_style( $style_tag_id );
    	}

    	// Prints out any other stores registered by themes or otherwise.
    	$additional_stores = WP_Style_Engine_CSS_Rules_Store::get_stores();
    	foreach ( array_keys( $additional_stores ) as $store_name ) {
    		if ( in_array( $store_name, $core_styles_keys, true ) ) {
    			continue;
    		}
    		$styles = wp_style_engine_get_stylesheet_from_context( $store_name, $options );
    		if ( ! empty( $styles ) ) {
    			$key = "wp-style-engine-$store_name";
    			wp_register_style( $key, false );
    			wp_add_inline_style( $key, $styles );
    			wp_enqueue_style( $key );
    		}
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/script-loader.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/script-loader.php#L3244)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/script-loader.php#L3244-L3295)

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

| Uses | Description | 
| [WP_Style_Engine_CSS_Rules_Store::get_stores()](https://developer.wordpress.org/reference/classes/wp_style_engine_css_rules_store/get_stores/)`wp-includes/style-engine/class-wp-style-engine-css-rules-store.php` |

Gets an array of all available stores.

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

Returns compiled CSS from a store, if found.

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

Returns whether the active theme is a block-based theme or not.

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

Registers a CSS stylesheet.

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

Adds extra CSS styles to a registered stylesheet.

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

Enqueues a CSS stylesheet.

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

Returns whether or not an action hook is currently being processed.

  |

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

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

| Version | Description | 
| [6.1.0](https://developer.wordpress.org/reference/since/6.1.0/) | Introduced. |

## User Contributed Notes

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