Archived topic
Including author avatar on post-meta not working on child theme
3 replies · Started by iniciaseo on October 15, 2021
Hello,
I am trying to include the author avatar in the post-meta template to get the photo to show in the category posts loop. I am doing it through the child theme (/generatepress_child/inc/structure/post-meta.php), but the modifications are not visible if I don't change it in the parent theme file.
Any idea? The modified code is this:
if ( 'author' === $item ) {
$schema_type = generate_get_schema_type();
$avatarphoto = get_avatar( get_the_author_meta( 'ID' ), '40') ;
$byline = '<span class="byline"><span style="width:50px;vertical-align: middle !important;">'.$avatarphoto.'</span> %1$s<span class="author%8$s" %5$s><a class="url fn n" href="%2$s" title="%3$s" rel="author"%6$s><span class="author-name"%7$s>%4$s</span></a></span></span> ';
Thanks in advance!
Hi there,
you can't simply overwrite that function, but you can filter its content using:generate_post_author_output
https://docs.generatepress.com/article/generate_post_author_output/
See Elvins reply here where he provides a snippet for including the avatar:
https://generatepress.com/forums/topic/hi-i-want-to-show-author-updated-date/page/3/#post-1652505
Or alternatively you can create your won custom content templates or post meta using the Block Element:
https://docs.generatepress.com/article/block-element-content-template/
https://docs.generatepress.com/article/block-element-post-meta-template/
Great! Elvin's code works perfectly! Thanks!!!
Glad to hear that!