# _delete_attachment_theme_mod()

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

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

## Сигнатура

```php
_delete_attachment_theme_mod( int $id )
```

## Описание

Если true, удаляет модификацию темы, которая указывала бы на удалённое вложение.

## Параметры

- `$id` `int` — обязательный. Идентификатор вложения.

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

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

```php
function _delete_attachment_theme_mod( $id ) {
	$attachment_image = wp_get_attachment_url( $id );
	$header_image     = get_header_image();
	$background_image = get_background_image();
	$custom_logo_id   = (int) get_theme_mod( 'custom_logo' );
	$site_logo_id     = (int) get_option( 'site_logo' );

	if ( $custom_logo_id && $custom_logo_id === $id ) {
		remove_theme_mod( 'custom_logo' );
		remove_theme_mod( 'header_text' );
	}

	if ( $site_logo_id && $site_logo_id === $id ) {
		delete_option( 'site_logo' );
	}

	if ( $header_image && $header_image === $attachment_image ) {
		remove_theme_mod( 'header_image' );
		remove_theme_mod( 'header_image_data' );
	}

	if ( $background_image && $background_image === $attachment_image ) {
		remove_theme_mod( 'background_image' );
	}
}
```

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

- 6.6.0 — Also removes site_logo option set by the site logo block.
- 4.5.0 — Also removes custom logo theme mods.
- 4.3.0 — Also removes header_image_data.
- 3.0.0 — Introduced.

## Связанные

Использует: [`get_header_image`](https://chugunov.pro/api-wordpress/functions/get_header_image/), [`get_background_image`](https://chugunov.pro/api-wordpress/functions/get_background_image/), [`remove_theme_mod`](https://chugunov.pro/api-wordpress/functions/remove_theme_mod/), [`get_theme_mod`](https://chugunov.pro/api-wordpress/functions/get_theme_mod/), [`delete_option`](https://chugunov.pro/api-wordpress/functions/delete_option/), [`wp_get_attachment_url`](https://chugunov.pro/api-wordpress/functions/wp_get_attachment_url/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).

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