I've found a few solutions to this but I am echoing some html and I have not been able to put those solutions (to return intead of echo, for example) to use. This is my function:
function get_loggedin_avatar (){global $current_user;
if ( is_user_logged_in() ):
get_currentuserinfo();
echo '<a href="/myaccount">';
echo get_avatar( $current_user->ID, 96, left );
echo '</a>';
endif; }
add_shortcode( 'loggedinavatar', 'get_loggedin_avatar' );
I see if I change all the echoes to returns, the avatar is output in the right spot but the link html stays at the top of the page.
I thought that perhaps making the html into variables that could be returned might work but I couldn't get that to work. Output buffering (or at least my attempt at it) did not work either.
** this is not a duplicate of this as output buffering did not work with my specific example.