-
-
Save billerickson/9421cc0c381d511aafc0dcd8a8b12345 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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