posts_orderby_request
云策文档标注
概述
posts_orderby_request 是一个 WordPress 过滤器,用于修改查询中的 ORDER BY 子句,主要供缓存插件使用。
关键要点
- 过滤器名称:posts_orderby_request
- 用途:过滤查询的 ORDER BY 子句,允许开发者自定义排序逻辑
- 参数:$orderby(ORDER BY 子句字符串)和 $query(WP_Query 实例,通过引用传递)
- 应用场景:常用于缓存插件优化查询性能
- 相关函数:在 WP_Query::get_posts() 中调用,位于 wp-includes/class-wp-query.php
- 版本历史:自 WordPress 2.5.0 引入
原文内容
Filters the ORDER BY clause of the query.
Description
For use by caching plugins.
Parameters
Source
$orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) );
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |