钩子文档

terms_clauses

💡 云策文档标注

概述

terms_clauses 是一个 WordPress 过滤器,用于修改术语查询的 SQL 子句。它允许开发者在执行 WP_Term_Query 时自定义查询结构。

关键要点

  • 过滤器名称:terms_clauses
  • 参数:$clauses(关联数组,包含查询子句如 SELECT、JOIN、WHERE 等)、$taxonomies(分类法名称数组)、$args(查询参数数组)
  • 用途:通过 apply_filters 调用,在 WP_Term_Query::get_terms() 中应用,用于调整术语查询的 SQL 语句
  • 引入版本:WordPress 3.1.0

📄 原文内容

Filters the terms query SQL clauses.

Parameters

$clausesstring[]
Associative array of the clauses for the query.

  • fields string
    The SELECT clause of the query.
  • join string
    The JOIN clause of the query.
  • where string
    The WHERE clause of the query.
  • distinct string
    The DISTINCT clause of the query.
  • orderby string
    The ORDER BY clause of the query.
  • order string
    The ORDER clause of the query.
  • limits string
    The LIMIT clause of the query.

$taxonomiesstring[]
An array of taxonomy names.
$argsarray
An array of term query arguments.

Source

$clauses = apply_filters( 'terms_clauses', compact( $pieces ), $taxonomies, $args );

Changelog

Version Description
3.1.0 Introduced.