钩子文档

delete_term

💡 云策文档标注

概述

delete_term 是一个 WordPress 动作钩子,在术语从数据库删除且缓存清理后触发。它允许开发者执行自定义操作,如清理相关数据或更新其他系统。

关键要点

  • 触发时机:术语删除后,数据库和缓存已清理时。
  • 特定钩子:提供 'delete_$taxonomy' 钩子,用于针对特定分类法。
  • 参数:包括 $term(术语ID)、$tt_id(术语分类法ID)、$taxonomy(分类法slug)、$deleted_term(已删除术语的WP_Term副本)、$object_ids(术语对象ID列表)。
  • 相关函数:与 wp_delete_term() 函数关联,用于从数据库移除术语。
  • 版本历史:从 WordPress 2.5.0 引入,4.5.0 版本添加了 $object_ids 参数。

📄 原文内容

Fires after a term is deleted from the database and the cache is cleaned.

Description

The ‘delete_$taxonomy’ hook is also available for targeting a specific taxonomy.

Parameters

$termint
Term ID.
$tt_idint
Term taxonomy ID.
$taxonomystring
Taxonomy slug.
$deleted_termWP_Term
Copy of the already-deleted term.
$object_idsarray
List of term object IDs.

Source

do_action( 'delete_term', $term, $tt_id, $taxonomy, $deleted_term, $object_ids );

Changelog

Version Description
4.5.0 Introduced the $object_ids argument.
2.5.0 Introduced.