comments_popup_link_attributes
Filters the attributes of the link output by comments_popup_link().
Usage
add_filter( 'comments_popup_link_attributes', 'wp_kama_comments_popup_link_attributes_filter' );
/**
* Function for `comments_popup_link_attributes` filter-hook.
*
* @param string $link_attributes The comments link attributes.
*
* @return string
*/
function wp_kama_comments_popup_link_attributes_filter( $link_attributes ){
// filter...
return $link_attributes;
}
- $attributes(string)
- The link attributes.
Default: ''
Examples
#1 Add a custom data attribute
Add the data-postid attribute containing the post ID.
add_filter( 'comments_popup_link_attributes', 'filter_comments_popup_link_attributes' );
function filter_comments_popup_link_attributes( $attrs ) {
$my_attr = sprintf( 'data-postid="%d"', get_the_ID() );
return $attrs ? "$attrs $my_attr" : $my_attr;
}Changelog
| Since 2.5.0 | Introduced. |
Where the hook is called
comments_popup_link_attributes
wp-includes/comment-template.php 1712
$link_attributes = apply_filters( 'comments_popup_link_attributes', $link_attributes );