Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created May 31, 2019 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/9421cc0c381d511aafc0dcd8a8b12345 to your computer and use it in GitHub Desktop.
Save billerickson/9421cc0c381d511aafc0dcd8a8b12345 to your computer and use it in GitHub Desktop.
<?php
/**
* Display Posts, include_author_avatar parameter
* @see https://displayposts.com/2019/05/31/display-author-avatar/
*/
function be_dps_include_author_avatar( $output, $original_atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class, $author, $category_display_text ) {
if( empty( $original_atts['include_author_avatar'] ) || false === filter_var( $original_atts['include_author_avatar'], FILTER_VALIDATE_BOOLEAN ) )
return $output;
$size = !empty( $original_atts['avatar_size'] ) ? intval( $original_atts['avatar_size'] ) : 48;
$author .= get_avatar( get_the_author_meta( 'ID' ), $size );
$output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $image . $title . $date . $author . $category_display_text . $excerpt . $content . '</' . $inner_wrapper . '>';
return $output;
}
add_filter( 'display_posts_shortcode_output', 'be_dps_include_author_avatar', 10, 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment