How can I get a user avatar to display in the header of my WordPress site? I've tried:

<a href="<?php echo get_author_posts_url($post->post_author); ?>" title="<?php the_author_meta( 'display_name', $post->post_author ); ?>">
<?php if( get_the_author_meta( 'user_custom_avatar', $post->post_author ) != '' ) { ?>
    <img src="<?php the_author_meta( 'user_custom_avatar', $post->post_author ); ?>" alt="" />
    <?php echo $curauth->display_name; ?>
<?php } else { ?>
    <?php echo get_avatar( get_the_author_meta( 'user_email', $post->post_author ), '80' ); ?>
<?php } ?>
</a>

but every time the logged-in user goes to a different authors post, the avatar changes to that authors avatar. I want it to be that when a user logs in, his/her avatar stays on the top of the page all the time. Can this be done?

没有正确的解决方案

许可以下: CC-BY-SA归因
scroll top