pre_wp_list_authors_post_counts_query
云策文档标注
概述
pre_wp_list_authors_post_counts_query 是一个 WordPress 过滤器,用于在 wp_list_authors() 函数执行作者文章数量查询前,允许开发者短路或修改查询行为。
关键要点
- 过滤器名称:pre_wp_list_authors_post_counts_query
- 主要用途:过滤是否短路执行作者文章数量查询,可返回自定义的 post counts 数组或 false 以跳过默认查询
- 参数:$post_counts(文章数量数组或 false)和 $parsed_args(wp_list_authors() 的参数数组)
- 相关函数:wp_list_authors(),用于列出站点作者
- 引入版本:WordPress 6.1.0
原文内容
Filters whether to short-circuit performing the query for author post counts.
Parameters
$post_countsint[]|false-
Array of post counts, keyed by author ID.
$parsed_argsarray-
The arguments passed to wp_list_authors() combined with the defaults.
More Arguments from wp_list_authors( … $args )
Array or string of default arguments.
orderbystringHow to sort the authors. Accepts'nicename','email','url','registered','user_nicename','user_email','user_url','user_registered','name','display_name','post_count','ID','meta_value','user_login'. Default'name'.orderstringSorting direction for $orderby. Accepts'ASC','DESC'. Default'ASC'.numberintMaximum authors to return or display. Default empty (all authors).optioncountboolShow the count in parenthesis next to the author’s name. Default false.exclude_adminboolWhether to exclude the'admin'account, if it exists. Default true.show_fullnameboolWhether to show the author’s full name. Default false.hide_emptyboolWhether to hide any authors with no posts. Default true.feedstringIf not empty, show a link to the author’s feed and use this text as the alt parameter of the link. Default empty.feed_imagestringIf not empty, show a link to the author’s feed and use this image URL as clickable anchor. Default empty.feed_typestringThe feed type to link to. Possible values include'rss2','atom'.
Default is the value of get_default_feed() .echoboolWhether to output the result or instead return it. Default true.stylestringIf'list', each author is wrapped in an<li>element, otherwise the authors will be separated by commas.htmlboolWhether to list the items in HTML form or plaintext. Default true.excludeint[]|stringArray or comma/space-separated list of author IDs to exclude. Default empty.includeint[]|stringArray or comma/space-separated list of author IDs to include. Default empty.
Source
$post_counts = apply_filters( 'pre_wp_list_authors_post_counts_query', false, $parsed_args );
Changelog
| Version | Description |
|---|---|
| 6.1.0 | Introduced. |