sites_clauses
云策文档标注
概述
sites_clauses 是一个 WordPress 过滤器,用于修改 WP_Site_Query 查询中的 SQL 子句。它允许开发者自定义站点查询的 SELECT、JOIN、WHERE 等部分。
关键要点
- 过滤器名称:sites_clauses
- 参数:$clauses(关联数组,包含查询子句如 fields、join、where 等)和 $query(WP_Site_Query 实例,按引用传递)
- 用途:在 WP_Site_Query::get_site_ids() 内部使用,以获取匹配查询变量的站点 ID 列表
- 引入版本:WordPress 4.6.0
代码示例
$clauses = apply_filters_ref_array( 'sites_clauses', array( compact( $pieces ), &$this ) );
原文内容
Filters the site query clauses.
Parameters
$clausesstring[]-
Associative array of the clauses for the query.
fieldsstringThe SELECT clause of the query.joinstringThe JOIN clause of the query.wherestringThe WHERE clause of the query.orderbystringThe ORDER BY clause of the query.limitsstringThe LIMIT clause of the query.groupbystringThe GROUP BY clause of the query.
$queryWP_Site_Query-
Current instance of WP_Site_Query (passed by reference).
Source
$clauses = apply_filters_ref_array( 'sites_clauses', array( compact( $pieces ), &$this ) );
Changelog
| Version | Description |
|---|---|
| 4.6.0 | Introduced. |