Get avatar on meta for td_module_2.php

Posted in: Newspaper
Post count: 113

I’ve read all articles on this and none seem to work correctly, below is as close as I’ve gotten but it displays the wrong avatar for each author. Can you fix my code so that the correct avatar displays?

<div class="td-module-meta-info">
<?php echo get_avatar( get_the_author_meta( 'ID' )); ?>
<?php echo $this->get_author();?>
<?php echo $this->get_date();?>
<?php echo $this->get_comments();?>
</div>

Post count: 22421

Hello,

Sorry but our theme modules and blocks will not grab the avatar as those functions are only destined for posts. They do not work for our theme modules. A custom function built from scratch must be added that can provide this functionality for our modules and blocks. You will need to create it in the code, not just call it on the module. A custom function must be built in td_module_single.php and then called on the module as you mention. Unfortunately as you can imagine this requires coding skills to do. We suggest hiring a freelancer to help out with creating such a function.

Thank you!

Post count: 113

Thanks Bogdan,

Can td_module_single.php be overridden in the child theme?

David

Post count: 22421

Hello,

All of the files that can be rewritten from the child theme are found in this section of the theme docs: https://forum.tagdiv.com/the-child-theme-support-tutorial/
Td_+module_single is not among them unfortunately. If you plan on modifying this file, you will have to do it in the main theme files.

Thank you!

Post count: 113

we have it working without changes to the core theme files, we have added:

<?php echo get_avatar(get_the_author_meta('ID', $this->post->post_author)); ?>

to td_module_2.php in our child theme.

Viewing 5 posts - 1 through 5 (of 5 total)
The forum ‘Newspaper’ is closed to new topics and replies.