Copy and paste following code at the end of your child theme’s functions.php file (If you do not use child theme, please use Code Snippet plugin).
Side note: You can also directly paste the code at the end of main theme’s functions.php, however all changes will be lost on theme update.
/**
* New Entry meta function to include author avatar image.
*/
function bayleaf_custom_entry_meta() {
global $post;
?>
<span<?php bayleaf_attr( 'meta-author-avatar' ); ?>>
<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID', $post->post_author ) ) ); ?>"<?php bayleaf_attr( 'url' ); ?>><span<?php bayleaf_attr( 'name', false ); ?>> <?php echo get_avatar( get_the_author_meta( 'user_email', $post->post_author ), 36 ); ?></span></a>
</span><!-- .meta-author -->
<?php
bayleaf_entry_meta();
}
/**
* Modify entry meta callback function,
*/
function bayleaf_custom_modify_entry_meta() {
return [ 'bayleaf_custom_entry_meta' ];
}
add_filter( 'bayleaf_markup_entry_meta', 'bayleaf_custom_modify_entry_meta' );
This will add author picture before author name. Use .meta-author-avatar
and .meta-author-avatar img
class to add custom styling.
Always backup your site before making changes in PHP.