set_theme_mod( string $name, mixed $value )
Update theme modification value for the current theme.
Description Description
Parameters Parameters
- $name
-
(string) (Required) Theme modification name.
- $value
-
(mixed) (Required) Theme modification value.
Source Source
File: wp-includes/theme.php
function set_theme_mod( $name, $value ) {
$mods = get_theme_mods();
$old_value = isset( $mods[ $name ] ) ? $mods[ $name ] : false;
/**
* Filters the theme modification, or 'theme_mod', value on save.
*
* The dynamic portion of the hook name, `$name`, refers to the key name
* of the modification array. For example, 'header_textcolor', 'header_image',
* and so on depending on the theme options.
*
* @since 3.9.0
*
* @param string $value The new value of the theme modification.
* @param string $old_value The current value of the theme modification.
*/
$mods[ $name ] = apply_filters( "pre_set_theme_mod_{$name}", $value, $old_value );
$theme = get_option( 'stylesheet' );
update_option( "theme_mods_$theme", $mods );
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Sample usage, hooking into ‘init’
function wecodeart_theme_mods() { set_theme_mod('my_mod_one', 'new_mode_one_value'); } add_action( 'init', 'wecodeart_theme_mods' );