钩子文档

term_exists_default_query_args

💡 云策文档标注

概述

本文档介绍 term_exists_default_query_args 过滤器,用于在检查术语是否存在时过滤传递给 get_terms() 的默认查询参数。它允许开发者自定义查询条件,如限制父术语或调整搜索范围。

关键要点

  • 过滤器名称:term_exists_default_query_args
  • 用途:过滤 term_exists() 函数中用于检查术语存在的默认查询参数
  • 参数:$defaults(数组,传递给 get_terms() 的参数)、$term(术语 ID、slug 或名称)、$taxonomy(分类法名称,空字符串表示搜索所有分类法)、$parent_term(父术语 ID,null 表示无限制)
  • 引入版本:WordPress 6.0.0
  • 相关函数:term_exists(),位于 wp-includes/taxonomy.php

📄 原文内容

Filters default query arguments for checking if a term exists.

Parameters

$defaultsarray
An array of arguments passed to get_terms() .

More Arguments from get_terms( … $args )

Array or string of arguments. See WP_Term_Query::__construct() for information on accepted arguments.

$termint|string
The term to check. Accepts term ID, slug, or name.
$taxonomystring
The taxonomy name to use. An empty string indicates the search is against all taxonomies.
$parent_termint|null
ID of parent term under which to confine the exists search.
Null indicates the search is unconfined.

Source

$defaults = apply_filters( 'term_exists_default_query_args', $defaults, $term, $taxonomy, $parent_term );

Changelog

Version Description
6.0.0 Introduced.