WordPress at Your Fingertips

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.

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 5.8.1

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

Other Theme Functions

vladlu 100vlad.lu
Editors: Kama 100
No comments
    Log In