On this page
remove_theme_mod( string $name )
Removes theme modification name from active theme list.
Description
If removing the name also removes all elements, then the entire option will be removed.
Parameters
$namestring Required-
Theme modification name.
Source
File: wp-includes/theme.php. View all references
function remove_theme_mod( $name ) {
$mods = get_theme_mods();
if ( ! isset( $mods[ $name ] ) ) {
return;
}
unset( $mods[ $name ] );
if ( empty( $mods ) ) {
remove_theme_mods();
return;
}
$theme = get_option( 'stylesheet' );
update_option( "theme_mods_$theme", $mods );
}
Related
Uses
| Uses | Description |
|---|---|
| remove_theme_mods() wp-includes/theme.php | Removes theme modifications option for the active theme. |
| get_theme_mods() wp-includes/theme.php | Retrieves all theme modifications. |
| update_option() wp-includes/option.php | Updates the value of an option that was already added. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Used By
| Used By | Description |
|---|---|
| Custom_Image_Header::set_header_image() wp-admin/includes/class-custom-image-header.php | Choose a header image, selected from existing uploaded and default headers, or provide an array of uploaded header data (either new, or from media library). |
| Custom_Background::take_action() wp-admin/includes/class-custom-background.php | Executes custom background modification. |
| _delete_attachment_theme_mod() wp-includes/theme.php | Checks an attachment being deleted to see if it’s a header or background image. |
| switch_theme() wp-includes/theme.php | Switches the theme. |
| WP_Customize_Background_Image_Setting::update() wp-includes/customize/class-wp-customize-background-image-setting.php |
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/remove_theme_mod