钩子文档

edit_attachment

💡 云策文档标注

概述

edit_attachment 是一个 WordPress 动作钩子,在现有附件更新后触发,主要用于处理附件数据变更时的自定义操作。

关键要点

  • 触发时机:当现有附件(attachment)被更新时触发。
  • 参数:$post_id(整数类型),表示附件的 ID。
  • 源调用:do_action( 'edit_attachment', $post_id )。
  • 相关函数:wp_insert_post() 用于插入或更新帖子(包括附件)。
  • 版本历史:自 WordPress 2.0.0 版本引入。

📄 原文内容

Fires once an existing attachment has been updated.

Parameters

$post_idint
Attachment ID.

Source

do_action( 'edit_attachment', $post_id );

Changelog

Version Description
2.0.0 Introduced.