Title: WP_Customize_Custom_CSS_Setting::update
Published: December 6, 2016
Last modified: August 20, 2026

---

# WP_Customize_Custom_CSS_Setting::update( string $value ): int|false

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#changelog)

Store the CSS setting value in the custom_css custom post type for the stylesheet.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#parameters)󠁿

 `$value`stringrequired

CSS to update.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#return)󠁿

 int|false The post ID or false if the value could not be saved.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#source)󠁿

    ```php
    public function update( $value ) {
    	// Restores the more descriptive, specific name for use within this method.
    	$css = $value;

    	if ( empty( $css ) ) {
    		$css = '';
    	}

    	$r = wp_update_custom_css_post(
    		$css,
    		array(
    			'stylesheet' => $this->stylesheet,
    		)
    	);

    	if ( is_wp_error( $r ) ) {
    		return false;
    	}

    	$post_id = $r->ID;

    	// Cache post ID in theme mod for performance to avoid additional DB query.
    	if ( $this->manager->get_stylesheet() === $this->stylesheet ) {
    		set_theme_mod( 'custom_css_post_id', $post_id );
    	}

    	return $post_id;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/customize/class-wp-customize-custom-css-setting.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/customize/class-wp-customize-custom-css-setting.php#L255)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/customize/class-wp-customize-custom-css-setting.php#L255-L282)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_update_custom_css_post()](https://developer.wordpress.org/reference/functions/wp_update_custom_css_post/)`wp-includes/theme.php` |

Updates the `custom_css` post for a given theme.

  | 
| [set_theme_mod()](https://developer.wordpress.org/reference/functions/set_theme_mod/)`wp-includes/theme.php` |

Updates theme modification value for the active theme.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_custom_css_setting/update/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Renamed `$css` to `$value` for PHP 8 named parameter support. | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_custom_css_setting%2Fupdate%2F)
before being able to contribute a note or feedback.