WordPress at Your Fingertips

wp_add_inline_style() WP 1.0

Add extra CSS styles to a registered stylesheet.

Styles will only be added if the stylesheet is already in the queue. Accepts a string $data containing the CSS. If two or more CSS code blocks are added to the same stylesheet $handle, they will be printed in the order they were added, i.e. the latter added styles can redeclare the previous.

No Hooks.


true|false. True on success, false on failure.


wp_add_inline_style( $handle, $data );
$handle(string) (required)
Name of the stylesheet to add the extra styles to.
$data(string) (required)
String containing the CSS styles to be added.



Since 3.3.0 Introduced.

Code of wp_add_inline_style() WP 5.7.2

function wp_add_inline_style( $handle, $data ) {
	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );

	if ( false !== stripos( $data, '</style>' ) ) {
				/* translators: 1: <style>, 2: wp_add_inline_style() */
				__( 'Do not pass %1$s tags to %2$s.' ),
		$data = trim( preg_replace( '#<style[^>]*>(.*)</style>#is', '$1', $data ) );

	return wp_styles()->add_inline_style( $handle, $data );

From tag: styles (include files)

More from category: Scripts and Styles

No comments
    Log In