trashed_post
云策文档标注
概述
trashed_post 是一个 WordPress 动作钩子,在文章被移动到回收站后触发,用于执行相关操作。
关键要点
- 触发时机:文章被发送到回收站后立即执行。
- 参数:$post_id(文章 ID,整数类型)和 $previous_status(文章被移动到回收站前的状态,字符串类型)。
- 版本历史:WordPress 6.3.0 版本添加了 $previous_status 参数,2.9.0 版本引入此钩子。
- 相关函数:与 wp_trash_post() 和 WP_Customize_Manager::trash_changeset_post() 等函数关联。
代码示例
do_action( 'trashed_post', $post_id, $previous_status );
原文内容
Fires after a post is sent to the Trash.
Parameters
$post_idint-
Post ID.
$previous_statusstring-
The status of the post at the point where it was trashed.
Source
do_action( 'trashed_post', $post_id, $previous_status );