I would use something like this instead:
$coauthors = get_coauthors();
foreach( $coauthors as $coauthor ):
echo $coauthor->description;
echo get_avatar( $coauthor->user_email );
endforeach;
jh, have you found a solution to this issue?
I am using the following to display author info, but like jh, this code wants to insert a gravatar for the co-authors, even if they don’t have an email defined:
// About Author
if(get_post_meta($post->ID, 'post-option-author-info-enabled', true) == "Yes"){
$i = new CoAuthorsIterator();
while($i->iterate()){
echo "<div class='about-author-wrapper'>";
echo "<div class='about-author-avartar'>" . get_avatar( get_the_author_meta('ID'), 90 ) . "</div>";
echo "<div class='about-author-info'>";
echo "<div class='about-author-title gdl-link-title gdl-title'>";
echo the_author_firstname();
echo " ";
echo the_author_lastname();
echo "</div>";
echo the_author_description();
echo " All posts by ";
echo the_author_posts_link('namefl');
echo "</div>";
echo "<div class='clear'></div>";
echo "</div>";
}
}
Any ideas how I might show featured image if one is defined for Guest Author?
(Sorry if you’ve addressed this elsewhere, but there are a number of posts looking for similar functionality, but many of them prescribe a different course of action.)
Thanks, Daniel!
GDW
RE: my post above, I have come to discover that my issue is particular to either my theme or PHP settings. If I hardcode an author email in the call below, it calls up the Guest Author’s featured image:
get_avatar(the_author_email(), 90 )
Question: Can we call the image using anything other than email?
Thanks,
GDW
Here’s what I’ve ended up using:
// About Author
if(get_post_meta($post->ID, 'post-option-author-info-enabled', true) == "Yes"){
$coauthors = get_coauthors();
foreach( $coauthors as $coauthor ):
echo "<div class='about-author-wrapper'>";
echo "<div class='about-author-avartar'>". get_avatar($coauthor->user_email, 90) ."</div>";
echo "<div class='about-author-info'><div class='about-author-title gdl-link-title gdl-title'>". $coauthor->first_name ." ". $coauthor->last_name ."</div>";
echo $coauthor->description;
echo "</div>";
echo "<div class='clear'></div>";
echo "</div>";
endforeach;
}
And lastly, here it is with links to “All posts by Co-Author Name” links both in the description text and a link on the avatar:
// About Author
if(get_post_meta($post->ID, 'post-option-author-info-enabled', true) == "Yes"){
$coauthors = get_coauthors();
foreach( $coauthors as $coauthor ):
echo "<div class='about-author-wrapper'>";
echo "<div class='about-author-avartar'><a href='". get_author_posts_url( $coauthor->ID, $coauthor->user_nicename )."'>". get_avatar($coauthor->user_email, 90, '', $coauthor->display_name) ."</a></div>";
echo "<div class='about-author-info'><div class='about-author-title gdl-link-title gdl-title'>". $coauthor->display_name ."</div>";
echo $coauthor->description;
echo " View all posts by <a href='". get_author_posts_url( $coauthor->ID, $coauthor->user_nicename )."'>". $coauthor->display_name ."</a>.";
echo "</div>";
echo "<div class='clear'></div>";
echo "</div>";
endforeach;
}
Thanks for your persistence tracking this down, gdfwilliams. It should be useful for other people that come across the thread as well.
As of v3.0.2, the avatar will only be shown for a guest author if there’s an email in the email field. It doesn’t necessarily have to be an accurate email, but checking the email address against profiles is how we determine if the avatar should be filtered.
I did this because guest authors are actually a custom post type. As such, a guest author could have 5 as an ID. If we also filtered based on IDs passed to get_avatar(), then the guest author would override a user with ID of 5.
Imperfect, I know, but it was the best solution I could come up with for now. Hope this helps clarify.
Happy to help, Daniel. Thanks again for all your hard work!
Would it be possible to display the featured image uploaded on a guest profile as avatar, without filling in the email field?
Would it be possible to display the featured image uploaded on a guest profile as avatar, without filling in the email field?
Not at this time, but you’re welcome to use a non-existent email address.
Alright! Thanks 🙂
1. And… how to display the ‘website link’ on the front?
2. Is it possible to use margins for the image?
1. The website link is available on the $author
variable, so something like: <?php echo $author->website_link; ?>
2. Sure, should be doable with some CSS.
Daniel, the $author->website_link is not working.
I mean: the website link on the co-author profile?
Oh, if you’re using the default field, it would be $author->website
Unfortunately, not working.
Can you share the code you’re using with Pastebin or similar?