wp_get_custom_css
Fetch the saved Custom CSS content for rendering.
Description
(string) wp_get_custom_css( (string) $stylesheet = '' );
Returns (string)
The Custom CSS Post content.
Parameters (1)
- 0. $stylesheet — Optional. (string) =>
''
- A theme object stylesheet name. Defaults to the current theme.
Usage
if ( !function_exists( 'wp_get_custom_css' ) ) { require_once ABSPATH . WPINC . '/theme.php'; } // Optional. A theme object stylesheet name. Defaults to the current theme. $stylesheet = ''; // NOTICE! Understand what this does before running. $result = wp_get_custom_css($stylesheet);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/theme.php
- function wp_get_custom_css( $stylesheet = '' ) {
- $css = '';
- if ( empty( $stylesheet ) ) {
- $stylesheet = get_stylesheet();
- }
- $post = wp_get_custom_css_post( $stylesheet );
- if ( $post ) {
- $css = $post->post_content;
- }
- /**
- * Modify the Custom CSS Output into the <head>.
- *
- * @since 4.7.0
- *
- * @param string $css CSS pulled in from the Custom CSS CPT.
- * @param string $stylesheet The theme stylesheet name.
- */
- $css = apply_filters( 'wp_get_custom_css', $css, $stylesheet );
- return $css;
- }