钩子文档

create_term

💡 云策文档标注

概述

create_term 是一个 WordPress Hook,在创建新分类法术语后立即触发,用于在术语缓存清理前执行自定义操作。此 Hook 还提供特定分类法的版本 create_$taxonomy。

关键要点

  • 触发时机:新术语创建后、术语缓存清理前
  • 参数:$term_id(术语 ID)、$tt_id(术语分类法 ID)、$taxonomy(分类法 slug)、$args(传递给 wp_insert_term() 的参数数组)
  • 相关函数:wp_insert_term() 用于向数据库添加新术语
  • 版本历史:6.1.0 版本添加了 $args 参数,2.3.0 版本引入

📄 原文内容

Fires immediately after a new term is created, before the term cache is cleaned.

Description

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

Parameters

$term_idint
Term ID.
$tt_idint
Term taxonomy ID.
$taxonomystring
Taxonomy slug.
$argsarray
Arguments passed to wp_insert_term() .

More Arguments from wp_insert_term( … $args )

Array or query string of arguments for inserting a term.

  • alias_of string
    Slug of the term to make this term an alias of.
    Accepts a term slug.
  • description string
    The term description.
  • parent int
    The id of the parent term. Default 0.
  • slug string
    The term slug to use.

Source

do_action( 'create_term', $term_id, $tt_id, $taxonomy, $args );

Changelog

Version Description
6.1.0 The $args parameter was added.
2.3.0 Introduced.