list_cats
云策文档标注
概述
list_cats 是一个 WordPress 过滤器,用于在显示分类法下拉元素前修改其参数。它允许开发者自定义下拉列表的选项,如“无选项”和“所有选项”的文本。
关键要点
- 过滤器名称:list_cats,用于过滤分类法下拉显示元素。
- 可修改参数:包括 'show_option_none'、'show_option_all' 和术语名称的各种形式。
- 相关函数:与 wp_dropdown_categories() 紧密关联,用于生成下拉列表。
- 引入版本:WordPress 1.2.0。
代码示例
$show_option_none = apply_filters( 'list_cats', $parsed_args['show_option_none'], null );注意事项
- 参数 $element 为字符串类型,表示分类名称;$category 为 WP_Term 对象或 null。
- 此过滤器在 Walker_Category 和 Walker_CategoryDropdown 的 start_el() 方法中使用,影响下拉元素的输出。
原文内容
Filters a taxonomy drop-down display element.
Description
A variety of taxonomy drop-down display elements can be modified just prior to display via this filter. Filterable arguments include ‘show_option_none’, ‘show_option_all’, and various forms of the term name.
See also
Parameters
$elementstring-
Category name.
$categoryWP_Term|null-
The category object, or null if there’s no corresponding category.
Source
$show_option_none = apply_filters( 'list_cats', $parsed_args['show_option_none'], null );
Changelog
| Version | Description |
|---|---|
| 1.2.0 | Introduced. |