Last active
July 20, 2018 18:18
-
-
Save wayphorier/808a299ea6ab07db78c1502953c02dc3 to your computer and use it in GitHub Desktop.
WordPress Post author link filter for adding Schema.org itemprop attribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function schema_org_author_posts_link( $link ) { | |
$link = sprintf( '<a itemprop="author" itemscope itemtype="https://schema.org/Person" href="%1$s" title="%2$s" rel="author"><span itemprop="name">%3$s</span></a>', | |
esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ), | |
/* translators: %s: author's display name */ | |
esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ), | |
get_the_author() | |
); | |
return $link; | |
} | |
add_filter( 'the_author_posts_link', 'schema_org_author_posts_link' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment