# wp_transition_post_status()

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

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

## Сигнатура

```php
wp_transition_post_status( string $new_status, string $old_status, WP_Post $post )
```

## Описание

При сохранении записи её статус «переводится» из одного в другой, хотя это не всегда означает, что статус действительно изменился до и после сохранения. Эта функция запускает несколько хуков-действий, связанных с этим переходом: обобщённое действие 'transition_post_status', а также динамические хуки '$old_status_to_$new_status' и '$new_status_$post->post_type'. Обратите внимание, что функция не переводит объект записи в базе данных.
Например, при первой публикации записи её статус может перейти из 'draft' — или другого статуса — в 'publish'. Однако если запись уже опубликована и просто обновляется, «старый» и «новый» статусы могут оба быть 'publish' до и после перехода.

## Параметры

- `$new_status` `string` — обязательный. Переход в этот статус записи.
- `$old_status` `string` — обязательный. Предыдущий статус записи.
- `$post` `WP_Post` — обязательный. Данные записи.

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

Файл: `wp-includes/post.php:5815`

```php
function wp_transition_post_status( $new_status, $old_status, $post ) {
	/**
	 * Fires when a post is transitioned from one status to another.
	 *
	 * @since 2.3.0
	 *
	 * @param string  $new_status New post status.
	 * @param string  $old_status Old post status.
	 * @param WP_Post $post       Post object.
	 */
	do_action( 'transition_post_status', $new_status, $old_status, $post );

	/**
	 * Fires when a post is transitioned from one status to another.
	 *
	 * The dynamic portions of the hook name, `$new_status` and `$old_status`,
	 * refer to the old and new post statuses, respectively.
	 *
	 * Possible hook names include:
	 *
	 *  - `draft_to_publish`
	 *  - `publish_to_trash`
	 *  - `pending_to_draft`
	 *
	 * @since 2.3.0
	 *
	 * @param WP_Post $post Post object.
	 */
	do_action( "{$old_status}_to_{$new_status}", $post );

	/**
	 * Fires when a post is transitioned from one status to another.
	 *
	 * The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
	 * refer to the new post status and post type, respectively.
	 *
	 * Possible hook names include:
	 *
	 *  - `draft_post`
	 *  - `future_post`
	 *  - `pending_post`
	 *  - `private_post`
	 *  - `publish_post`
	 *  - `trash_post`
	 *  - `draft_page`
	 *  - `future_page`
	 *  - `pending_page`
	 *  - `private_page`
	 *  - `publish_page`
	 *  - `trash_page`
	 *  - `publish_attachment`
	 *  - `trash_attachment`
	 *
	 * Please note: When this action is hooked using a particular post status (like
	 * 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
	 * first transitioned to that status from something else, as well as upon
	 * subsequent post updates (old and new status are both the same).
	 *
	 * Therefore, if you are looking to only fire a callback when a post is first
	 * transitioned to a status, use the 'transition_post_status' hook instead.
	 *
	 * @since 2.3.0
	 * @since 5.9.0 Added `$old_status` parameter.
	 *
	 * @param int     $post_id    Post ID.
	 * @param WP_Post $post       Post object.
	 * @param string  $old_status Old post status.
	 */
	do_action( "{$new_status}_{$post->post_type}", $post->ID, $post, $old_status );
}
```

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

- 2.3.0 — Introduced.

## Связанные

Использует: [`do_action`](https://chugunov.pro/api-wordpress/functions/do_action/).
Используется в: `WP_Customize_Manager::trash_changeset_post`, [`wp_publish_post`](https://chugunov.pro/api-wordpress/functions/wp_publish_post/), [`wp_insert_post`](https://chugunov.pro/api-wordpress/functions/wp_insert_post/).

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