remove_theme_mods()WP 2.1.0

Removes all special settings (options) of the theme set using set_theme_mod().

1 time — 0.0097179 sec (very slow) | 50000 times — 21.01 sec (slow) | PHP 8.2.25, WP 6.8.1

No Hooks.

Returns

null. Returns nothing.

Usage

remove_theme_mods();

Examples

0

#1 Delete all the theme settings

// let's say we added some options like this
set_theme_mod( 'my_thtme_option_a', 123 );
set_theme_mod( 'my_thtme_option_b', 'qqqq' );

// and here we need to remove all of the options. Delete:
remove_theme_mods();

Changelog

Since 2.1.0 Introduced.

remove_theme_mods() code WP 6.9.1

function remove_theme_mods() {
	delete_option( 'theme_mods_' . get_option( 'stylesheet' ) );

	// Old style.
	$theme_name = get_option( 'current_theme' );
	if ( false === $theme_name ) {
		$theme_name = wp_get_theme()->get( 'Name' );
	}

	delete_option( 'mods_' . $theme_name );
}