term_links-{$taxonomy}
云策文档标注
概述
此文档介绍 WordPress 中的动态 Hook term_links-{$taxonomy},用于过滤特定分类法的术语链接数组。Hook 名称中的 $taxonomy 部分动态替换为分类法 slug。
关键要点
- Hook 名称是动态的,例如 term_links-category、term_links-post_tag 和 term_links-post_format。
- 参数 $links 是一个字符串数组,表示术语链接。
- 此 Hook 在 get_the_term_list() 函数中使用,用于检索文章的术语列表。
- 自 WordPress 2.5.0 版本引入。
代码示例
$term_links = apply_filters( "term_links-{$taxonomy}", $links ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
原文内容
Filters the term links for a given taxonomy.
Description
The dynamic portion of the hook name, $taxonomy, refers to the taxonomy slug.
Possible hook names include:
term_links-categoryterm_links-post_tagterm_links-post_format
Parameters
$linksstring[]-
An array of term links.
Source
$term_links = apply_filters( "term_links-{$taxonomy}", $links ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |