found_posts_query
云策文档标注
概述
found_posts_query 是一个 WordPress 过滤器钩子,用于修改检索找到的帖子数量的查询。它允许开发者在 WP_Query 执行过程中自定义 FOUND_ROWS() 查询。
关键要点
- found_posts_query 是一个过滤器钩子,用于过滤检索找到的帖子数量的查询字符串。
- 它接受两个参数:$found_posts_query(查询字符串)和 $query(WP_Query 实例的引用)。
- 该钩子在 WP_Query::set_found_posts() 方法中被调用,用于设置找到的帖子数量和分页信息。
- 自 WordPress 2.1.0 版本引入。
代码示例
$found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) );
原文内容
Filters the query to run for retrieving the found posts.
Parameters
Source
$found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) );
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |