wp_deregister_style()WP 2.1.0

Cancels the registration of a CSS stylesheet.

The function may be useful when re-registering styles is needed, when you need to change the stylesheet file but keep the previous identifier. Styles are connected in the template through the identifier, using the function wp_enqueue_style().

Use wp_dequeue_style() when you just need to remove styles from the output, but do not need to completely delete the stylesheet file from the global data of registered styles.

To register a stylesheet file, use wp_register_style().

Uses the class WP_Styles and global $wp_styles.

1 time — -0.00003 sec (speed of light) | 50000 times — 0.02 sec (speed of light) | PHP 7.4.8, WP 5.8.1

No Hooks.

Returns

null. Returns nothing.

Usage

wp_deregister_style( $handle );
$handle(string) (required)
The name (identifier) of the styles that was used during registration in wp_register_style().

Examples

0

#1 Unregister the styles file

Suppose style with ID my_style was registered on init hook and we need to delete that style registration:

add_action( 'init', 'remove_my_style_stylesheet', 99 );

function remove_my_style_stylesheet() {

	wp_deregister_style( 'my_style' );
}

Notes

Changelog

Since 2.1.0 Introduced.

wp_deregister_style() code WP 6.8.3

function wp_deregister_style( $handle ) {
	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );

	wp_styles()->remove( $handle );
}