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

  1. if ( !function_exists( 'wp_get_custom_css' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4. // Optional. A theme object stylesheet name. Defaults to the current theme. 
  5. $stylesheet = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_get_custom_css($stylesheet); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function wp_get_custom_css( $stylesheet = '' ) { 
  2. $css = ''; 
  3.  
  4. if ( empty( $stylesheet ) ) { 
  5. $stylesheet = get_stylesheet(); 
  6.  
  7. $post = wp_get_custom_css_post( $stylesheet ); 
  8. if ( $post ) { 
  9. $css = $post->post_content; 
  10.  
  11. /** 
  12. * Modify the Custom CSS Output into the <head>. 
  13. * @since 4.7.0 
  14. * @param string $css CSS pulled in from the Custom CSS CPT. 
  15. * @param string $stylesheet The theme stylesheet name. 
  16. */ 
  17. $css = apply_filters( 'wp_get_custom_css', $css, $stylesheet ); 
  18.  
  19. return $css;