функция
since 5.6.0
wp_after_insert_post()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_after_insert_post( int|WP_Post $post, bool $update, null|WP_Post $post_before )
Описание
Запускает действия после сохранения записи, её терминов и метаданных.
Параметры
$post
int|WP_Post
обязательный
ID или объект сохранённой записи.
$update
bool
обязательный
Является ли это обновлением существующей записи.
$post_before
null|WP_Post
обязательный
Null для новых записей или объект WP_Post до обновления для обновляемых записей.
Исходный код
wp-includes/post.php:5896
function wp_after_insert_post( $post, $update, $post_before ) {
$post = get_post( $post );
if ( ! $post ) {
return;
}
$post_id = $post->ID;
/**
* Fires once a post, its terms and meta data has been saved.
*
* @since 5.6.0
*
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
* @param bool $update Whether this is an existing post being updated.
* @param null|WP_Post $post_before Null for new posts, the WP_Post object prior
* to the update for updated posts.
*/
do_action( 'wp_after_insert_post', $post_id, $post, $update, $post_before );
}
История изменений
| Версия | Описание |
|---|---|
| 5.6.0 | Introduced. |

