钩子文档

post_action_{$action}

💡 云策文档标注

概述

post_action_{$action} 是一个 WordPress 动态 Hook,用于在自定义文章操作请求时触发。它允许开发者根据特定操作执行自定义代码。

关键要点

  • 这是一个动态 Hook,$action 部分表示自定义文章操作名称。
  • Hook 接收一个参数:$post_id,即请求中发送的文章 ID。
  • 首次引入于 WordPress 4.6.0 版本。

代码示例

do_action( "post_action_{$action}", $post_id );

📄 原文内容

Fires for a given custom post action request.

Description

The dynamic portion of the hook name, $action, refers to the custom post action.

Parameters

$post_idint
Post ID sent with the request.

Source

do_action( "post_action_{$action}", $post_id );

Changelog

Version Description
4.6.0 Introduced.