Skip to content

Instantly share code, notes, and snippets.

@wayphorier
Last active July 20, 2018 18:18
Show Gist options
  • Save wayphorier/808a299ea6ab07db78c1502953c02dc3 to your computer and use it in GitHub Desktop.
Save wayphorier/808a299ea6ab07db78c1502953c02dc3 to your computer and use it in GitHub Desktop.
WordPress Post author link filter for adding Schema.org itemprop attribute
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