term_search_min_chars
云策文档标注
概述
此文档介绍 WordPress 中的 term_search_min_chars 过滤器,用于设置通过 Ajax 触发标签搜索所需的最小字符数。开发者可以自定义此参数以优化搜索行为。
关键要点
- term_search_min_chars 是一个过滤器,控制 Ajax 标签搜索的最小字符数阈值。
- 默认值为 2 个字符,可通过 apply_filters 函数进行修改。
- 过滤器接受三个参数:$characters(最小字符数)、$taxonomy_object(分类法对象)和 $search(搜索词)。
- 此过滤器在 WordPress 4.0.0 版本中引入,主要用于 wp_ajax_ajax_tag_search() 函数。
原文内容
Filters the minimum number of characters required to fire a tag search via Ajax.
Parameters
$charactersint-
The minimum number of characters required. Default 2.
$taxonomy_objectWP_Taxonomy-
The taxonomy object.
$searchstring-
The search term.
Source
$term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $taxonomy_object, $search );
Changelog
| Version | Description |
|---|---|
| 4.0.0 | Introduced. |