tag_link
云策文档标注
概述
tag_link 是一个 WordPress 过滤器钩子,用于修改标签链接的 URL。它允许开发者自定义标签归档页面的永久链接。
关键要点
- tag_link 过滤器接收两个参数:$termlink(标签链接 URL)和 $term_id(标签 ID)。
- 该过滤器在 get_term_link() 函数中被调用,用于生成分类法术语归档的永久链接。
- tag_link 在 WordPress 5.4.1 版本中恢复使用,之前曾被弃用,推荐使用 term_link 过滤器。
代码示例
$termlink = apply_filters( 'tag_link', $termlink, $term->term_id );注意事项
- tag_link 过滤器在 WordPress 2.3.0 中引入,2.5.0 版本被弃用,推荐使用 term_link 过滤器,但在 5.4.1 版本中恢复,因此开发者需注意版本兼容性。
- 相关函数包括 get_term_link(),位于 wp-includes/taxonomy.php 文件中。
原文内容
Filters the tag link.
Parameters
$termlinkstring-
Tag link URL.
$term_idint-
Term ID.
Source
$termlink = apply_filters( 'tag_link', $termlink, $term->term_id );
Changelog
| Version | Description |
|---|---|
| 5.4.1 | Restored (un-deprecated). |
| 2.5.0 | Deprecated in favor of ‘term_link’ filter. |
| 2.3.0 | Introduced. |