Skip to content

Instantly share code, notes, and snippets.

/template-tags.php

Created Nov 2, 2017
Embed
What would you like to do?
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
You can’t perform that action at this time.