set_theme_mod()
Update theme modification value for the current theme.
Uses: get_theme_mods(), update_option()
1 time — 0.000983 sec (slow) | 50000 times — 4.90 sec (fast)
Hooks from the function
Return
true|false
. True if the value was updated, false otherwise.
Usage
set_theme_mod( $name, $value );
- $name(string) (required)
- Theme modification name.
- $value(mixed) (required)
- Theme modification value.
Examples
#1 Set the themes option
Install and get a special setup of the theme:
add_action( 'switch_theme', 'wp_kama_theme_mods' ); function wp_kama_theme_mods() { set_theme_mod( 'my_mod_one', 'new_mode_one_value' ); }
Then get this option where needed:
get_theme_mod( 'my_mod_one' ); // > 123
Changelog
Since 2.1.0 | Introduced. |
Since 5.6.0 | A return value was added. |