remove_theme_mod()
Remove theme modification name from current theme list.
If removing the name also removes all elements, then the entire option will be removed.
1 time — 0.001562 sec (very slow) | 50000 times — 2.79 sec (fast)
No Hooks.
Return
null
. Ничего (null).
Usage
remove_theme_mod( $name );
- $name(string) (required)
- Theme modification name.
Examples
#1 Deleting special options
// let's say we added an option like this set_theme_mod( 'my_theme_option', 123 ); //and here we need to remove the option. Delete: remove_theme_mod( 'my_theme_option' );
Changelog
Since 2.1.0 | Introduced. |
remove_theme_mod() remove theme mod code WP 6.3
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 ); }