钩子文档

untrashed_post

💡 云策文档标注

概述

untrashed_post 是一个 WordPress 动作钩子,在文章从回收站恢复后触发。它提供了文章 ID 和之前的文章状态作为参数,用于开发者执行自定义操作。

关键要点

  • untrashed_post 钩子在文章从回收站恢复后立即触发。
  • 参数包括 $post_id(文章 ID)和 $previous_status(文章被移至回收站前的状态)。
  • 此钩子自 WordPress 2.9.0 引入,并在 5.6.0 版本添加了 $previous_status 参数。
  • 相关函数 wp_untrash_post() 用于从回收站恢复文章。

代码示例

do_action( 'untrashed_post', $post_id, $previous_status );

📄 原文内容

Fires after a post is restored from the Trash.

Parameters

$post_idint
Post ID.
$previous_statusstring
The status of the post at the point where it was trashed.

Source

do_action( 'untrashed_post', $post_id, $previous_status );

Changelog

Version Description
5.6.0 Added the $previous_status parameter.
2.9.0 Introduced.