# get_theme_mod()

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

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

## Сигнатура

```php
get_theme_mod( string $name, mixed $default_value = false ): mixed
```

## Описание

Если имя модификации не существует, а $default_value является строкой, значение по умолчанию будет пропущено через PHP-функцию sprintf() с URI каталога шаблона в качестве первого значения и URI каталога таблицы стилей в качестве второго.

## Параметры

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

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

`mixed`

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

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

```php
function get_theme_mod( $name, $default_value = false ) {
	$mods = get_theme_mods();

	if ( isset( $mods[ $name ] ) ) {
		/**
		 * Filters the theme modification, or 'theme_mod', value.
		 *
		 * 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 2.2.0
		 *
		 * @param mixed $current_mod The value of the active theme modification.
		 */
		return apply_filters( "theme_mod_{$name}", $mods[ $name ] );
	}

	if ( is_string( $default_value ) ) {
		// Only run the replacement if an sprintf() string format pattern was found.
		if ( preg_match( '#(?<!%)%(?:\d+\$?)?s#', $default_value ) ) {
			// Remove a single trailing percent sign.
			$default_value = preg_replace( '#(?<!%)%$#', '', $default_value );
			$default_value = sprintf( $default_value, get_template_directory_uri(), get_stylesheet_directory_uri() );
		}
	}

	/** This filter is documented in wp-includes/theme.php */
	return apply_filters( "theme_mod_{$name}", $default_value );
}
```

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

- 2.1.0 — Introduced.

## Связанные

Использует: [`get_theme_mods`](https://chugunov.pro/api-wordpress/functions/get_theme_mods/), [`get_template_directory_uri`](https://chugunov.pro/api-wordpress/functions/get_template_directory_uri/), [`get_stylesheet_directory_uri`](https://chugunov.pro/api-wordpress/functions/get_stylesheet_directory_uri/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`_wp_block_theme_register_classic_sidebars`](https://chugunov.pro/api-wordpress/functions/_wp_block_theme_register_classic_sidebars/), `WP_REST_Server::add_site_logo_to_index`, [`get_media_states`](https://chugunov.pro/api-wordpress/functions/get_media_states/), [`wp_map_sidebars_widgets`](https://chugunov.pro/api-wordpress/functions/wp_map_sidebars_widgets/), [`wp_get_custom_css_post`](https://chugunov.pro/api-wordpress/functions/wp_get_custom_css_post/), [`get_header_video_url`](https://chugunov.pro/api-wordpress/functions/get_header_video_url/), [`_custom_logo_header_styles`](https://chugunov.pro/api-wordpress/functions/_custom_logo_header_styles/), [`has_custom_logo`](https://chugunov.pro/api-wordpress/functions/has_custom_logo/), [`get_custom_logo`](https://chugunov.pro/api-wordpress/functions/get_custom_logo/), `WP_Customize_Setting::get_root_value`, `Custom_Image_Header::show_header_selector`, `Custom_Background::admin_page`, [`get_background_color`](https://chugunov.pro/api-wordpress/functions/get_background_color/), [`_custom_background_cb`](https://chugunov.pro/api-wordpress/functions/_custom_background_cb/), [`_delete_attachment_theme_mod`](https://chugunov.pro/api-wordpress/functions/_delete_attachment_theme_mod/), [`get_header_textcolor`](https://chugunov.pro/api-wordpress/functions/get_header_textcolor/), [`display_header_text`](https://chugunov.pro/api-wordpress/functions/display_header_text/), [`get_header_image`](https://chugunov.pro/api-wordpress/functions/get_header_image/), [`_get_random_header_data`](https://chugunov.pro/api-wordpress/functions/_get_random_header_data/), [`is_random_header_image`](https://chugunov.pro/api-wordpress/functions/is_random_header_image/), [`get_custom_header`](https://chugunov.pro/api-wordpress/functions/get_custom_header/), [`get_background_image`](https://chugunov.pro/api-wordpress/functions/get_background_image/), [`switch_theme`](https://chugunov.pro/api-wordpress/functions/switch_theme/), [`get_nav_menu_locations`](https://chugunov.pro/api-wordpress/functions/get_nav_menu_locations/), [`retrieve_widgets`](https://chugunov.pro/api-wordpress/functions/retrieve_widgets/).

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