previous_comments_link_attributes
云策文档标注
概述
previous_comments_link_attributes 是一个 WordPress 过滤器钩子,用于修改上一页评论链接的锚标签属性。它允许开发者自定义链接的 HTML 属性,如添加类名或样式。
关键要点
- 这是一个过滤器钩子,用于过滤上一页评论链接的锚标签属性。
- 参数 $attributes 是一个字符串,表示锚标签的属性。
- 钩子通过 apply_filters('previous_comments_link_attributes', '') 调用,初始值为空字符串。
- 与 get_previous_comments_link() 函数相关,用于检索上一页评论的链接。
- 自 WordPress 2.7.0 版本引入。
代码示例
function wpdocs_comments_link_attributes() {
return 'class="your-class-name"';
}
add_filter( 'previous_comments_link_attributes', 'wpdocs_comments_link_attributes' );
原文内容
Filters the anchor tag attributes for the previous comments page link.
Parameters
$attributesstring-
Attributes for the anchor tag.
Source
$attr = apply_filters( 'previous_comments_link_attributes', '' );
Changelog
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |
Skip to note 2 content
Razon Komar Pal
To add class in
previous linktag:function wpdocs_comments_link_attributes() { return 'class="your-class-name"'; } add_filter( 'previous_comments_link_attributes', 'wpdocs_comments_link_attributes' );