WordPress at a glance

wp_custom_css_cb() WP 4.7.0

Displays <style> tag containing CSS styles added in "Additional CSS" pane of the Theme Customizer.

Before displaying, the code of the styles is sanitized with the strip_tags() function.

To get these CSS styles without displaying them, use wp_get_custom_css().

This function is called by WordPress automatically on wp_head action and output current theme styles.

Works based on: wp_get_custom_css()

No Hooks.


Null. Nothing.




#1 Additional CSS styles from Theme Customizer (from settings)

The following code is used by default in WordPress to display styles in the HEAD part of the document:

add_action( 'wp_head', 'wp_custom_css_cb', 101 );

I.E. WordPress automatically adds Additional styles for any theme!


Since 4.7.0 Introduced.

Code of wp custom css cb: wp-includes/theme.php WP 5.2.4

function wp_custom_css_cb() {
	$styles = wp_get_custom_css();
	if ( $styles || is_customize_preview() ) :
		<style type="text/css" id="wp-custom-css">
			<?php echo strip_tags( $styles ); // Note that esc_html() cannot be used because `div &gt; span` is not interpreted properly. ?>

Related Functions

From category: Other Theme Functions

vladlu 100vlad.lu
Editors: kama 100
No comments
    Hello, !     Log In . Register