钩子文档

wp_list_authors_args

💡 云策文档标注

概述

wp_list_authors_args 是一个 WordPress 过滤器,用于修改 wp_list_authors() 函数中获取作者列表的查询参数。它允许开发者自定义作者列表的排序、显示选项等行为。

关键要点

  • 过滤器名称:wp_list_authors_args,用于过滤作者列表的查询参数。
  • 参数:$query_args(传递给 get_users() 的查询参数数组)和 $parsed_args(wp_list_authors() 的默认参数与传入参数合并后的数组)。
  • 支持多种参数,如 orderby(排序字段)、order(排序方向)、number(返回作者数量)、optioncount(显示文章计数)、exclude_admin(排除管理员)等。
  • 引入版本:WordPress 6.1.0。

代码示例

$query_args = apply_filters( 'wp_list_authors_args', $query_args, $parsed_args );

📄 原文内容

Filters the query arguments for the list of all authors of the site.

Parameters

$query_argsarray
The query arguments for get_users() .

More Arguments from get_users( … $args )

Arguments to retrieve users. See WP_User_Query::prepare_query() for more information on accepted arguments.

$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.

  • orderby string
    How 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'.
  • order string
    Sorting direction for $orderby. Accepts 'ASC', 'DESC'. Default 'ASC'.
  • number int
    Maximum authors to return or display. Default empty (all authors).
  • optioncount bool
    Show the count in parenthesis next to the author’s name. Default false.
  • exclude_admin bool
    Whether to exclude the 'admin' account, if it exists. Default true.
  • show_fullname bool
    Whether to show the author’s full name. Default false.
  • hide_empty bool
    Whether to hide any authors with no posts. Default true.
  • feed string
    If not empty, show a link to the author’s feed and use this text as the alt parameter of the link. Default empty.
  • feed_image string
    If not empty, show a link to the author’s feed and use this image URL as clickable anchor. Default empty.
  • feed_type string
    The feed type to link to. Possible values include 'rss2', 'atom'.
    Default is the value of get_default_feed() .
  • echo bool
    Whether to output the result or instead return it. Default true.
  • style string
    If 'list', each author is wrapped in an <li> element, otherwise the authors will be separated by commas.
  • html bool
    Whether to list the items in HTML form or plaintext. Default true.
  • exclude int[]|string
    Array or comma/space-separated list of author IDs to exclude. Default empty.
  • include int[]|string
    Array or comma/space-separated list of author IDs to include. Default empty.

Source

$query_args = apply_filters( 'wp_list_authors_args', $query_args, $parsed_args );

Changelog

Version Description
6.1.0 Introduced.