钩子文档

deleted_post_{$post->post_type}

💡 云策文档标注

概述

deleted_post_{$post->post_type} 是一个 WordPress 动作钩子,在文章从数据库删除后立即触发。钩子名称的动态部分基于文章类型,便于针对特定文章类型执行自定义操作。

关键要点

  • 触发时机:文章从数据库删除后立即执行。
  • 钩子名称:deleted_post_{$post->post_type},其中 {$post->post_type} 是文章类型的 slug,如 'post' 或 'page'。
  • 参数:$post_id(整数,文章 ID)和 $post(WP_Post 对象,文章对象)。
  • 相关函数:wp_delete_post() 用于删除或移至回收站文章。
  • 版本引入:WordPress 6.6.0 中首次引入。

📄 原文内容

Fires immediately after a post is deleted from the database.

Description

The dynamic portion of the hook name, $post->post_type, refers to the post type slug.

Parameters

$post_idint
Post ID.
$postWP_Post
Post object.

Source

do_action( "deleted_post_{$post->post_type}", $post_id, $post );

Changelog

Version Description
6.6.0 Introduced.