Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created May 31, 2019
Embed
What would you like to do?
<?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