Skip to content

Instantly share code, notes, and snippets.

Created November 2, 2017 14:50
Show Gist options
  • Save anonymous/c108cadc99075118357cc4cd7f9a6d1f to your computer and use it in GitHub Desktop.
Save anonymous/c108cadc99075118357cc4cd7f9a6d1f to your computer and use it in GitHub Desktop.
WordPress Entry Author Template Function
<?php
if ( ! function_exists( 'theme_slug_entry_author' ) ) :
/**
* Displays the post author
*/
function theme_slug_entry_author() {
$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" rel="author">%2$s</a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html( get_the_author() )
);
$posted_by = sprintf( esc_html_x( 'Published by %s', 'post author', 'theme-slug' ), $author );
return '<span class="meta-author"> ' . $posted_by . '</span>';
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment