comments_popup_link_attributes
Фильтрует атрибуты ссылки, которую выводит функция comments_popup_link().
Использование
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(cтрока)
- Атрибуты ссылки.
По умолчанию: ''
Примеры
#1 Добавим свой data атрибут
Добавит атрибут data-postid с 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;
}
Список изменений
| С версии 2.5.0 | Введена. |
Где вызывается хук
comments_popup_link_attributes
wp-includes/comment-template.php 1716
$link_attributes = apply_filters( 'comments_popup_link_attributes', $link_attributes );