# set_theme_mod()

URL: https://chugunov.pro/api-wordpress/functions/set_theme_mod/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.1.0.

## Сигнатура

```php
set_theme_mod( string $name, mixed $value ): bool
```

## Описание

Обновляет значение модификации темы для активной темы.

## Параметры

- `$name` `string` — обязательный. Имя модификации темы.
- `$value` `mixed` — обязательный. Значение модификации темы.

## Возвращаемое значение

`bool`

## Исходный код

Файл: `wp-includes/theme.php:1105`

```php
function set_theme_mod( $name, $value ) {
	$mods      = get_theme_mods();
	$old_value = $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 mixed $value     The new value of the theme modification.
	 * @param mixed $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' );

	return update_option( "theme_mods_$theme", $mods );
}
```

## История изменений

- 5.6.0 — A return value was added.
- 2.1.0 — Introduced.

## Связанные

Использует: [`get_theme_mods`](https://chugunov.pro/api-wordpress/functions/get_theme_mods/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`update_option`](https://chugunov.pro/api-wordpress/functions/update_option/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).
Используется в: `WP_REST_Menus_Controller::handle_locations`, [`_wp_menus_changed`](https://chugunov.pro/api-wordpress/functions/_wp_menus_changed/), [`wp_update_custom_css_post`](https://chugunov.pro/api-wordpress/functions/wp_update_custom_css_post/), [`wp_get_custom_css_post`](https://chugunov.pro/api-wordpress/functions/wp_get_custom_css_post/), `WP_Customize_Custom_CSS_Setting::update`, `WP_Customize_Setting::set_root_value`, [`wp_ajax_menu_locations_save`](https://chugunov.pro/api-wordpress/functions/wp_ajax_menu_locations_save/), `Custom_Image_Header::set_header_image`, `Custom_Image_Header::reset_header_image`, `Custom_Image_Header::take_action`, `Custom_Background::wp_set_background_image`, `Custom_Background::take_action`, `Custom_Background::handle_upload`, [`switch_theme`](https://chugunov.pro/api-wordpress/functions/switch_theme/), [`wp_delete_nav_menu`](https://chugunov.pro/api-wordpress/functions/wp_delete_nav_menu/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/set_theme_mod/
