Skip to content

Instantly share code, notes, and snippets.

@10h30
Last active August 29, 2015 14:27
Show Gist options
  • Save 10h30/ab57759688d501f1c80d to your computer and use it in GitHub Desktop.
Save 10h30/ab57759688d501f1c80d to your computer and use it in GitHub Desktop.
Modify Genesis Post Author shortcode to display outside the loop
add_filter ( 'genesis_post_author_posts_link_shortcode', 'filter_post_author_posts_link_shortcode', 10, 2);
function filter_post_author_posts_link_shortcode( $output, $atts ) {
global $post;
$id = ($post && property_exists($post,'post_author') && isset($post->post_author)) ? $post->post_author : 0;
$author = get_the_author_meta( 'display_name', $id);
$url = get_author_posts_url( $id );
$output = sprintf( '<span %s>', genesis_attr( 'entry-author' ) );
$output .= $atts['before'];
$output .= sprintf( '<a href="%s" %s>', $url, genesis_attr( 'entry-author-link' ) );
$output .= sprintf( '<span %s>', genesis_attr( 'entry-author-name' ) );
$output .= esc_html( $author );
$output .= '</span></a>' . $atts['after'] . '</span>';
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment