the_author_posts_link
Позволяет изменить html код ссылки на архивную страницу записей автора.
Использование
add_filter( 'the_author_posts_link', 'wp_kama_the_author_posts_link_filter' ); /** * Function for `the_author_posts_link` filter-hook. * * @param string $link HTML link. * * @return string */ function wp_kama_the_author_posts_link_filter( $link ){ // filter... return $link; }
- $link(строка)
- HTML код ссылки.
Примеры
#1 Изменим анкор ссылки на архив записей автора
Код практически 1 в 1 повторяет код функции get_the_author_posts_link():
add_filter( 'the_author_posts_link', 'filter_the_author_posts_link' ); function filter_the_author_posts_link( $link ) { global $authordata; if ( ! is_object( $authordata ) ) { return; } $link = sprintf( '<a href="%1$s" title="%2$s" rel="author">Остальные посты автора: %3$s</a>', esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ), esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ), get_the_author() ); return $link; }
Список изменений
С версии 2.9.0 | Введена. |
Где вызывается хук
the_author_posts_link
wp-includes/author-template.php 335
return apply_filters( 'the_author_posts_link', $link );