Display Author Avatar in Header
-
Hello,
I sent a previous thread, titled “Display Author Avatar Picture in Header,” but for some reason, the code wrapper didn’t trigger, so this is my most recent thread. The other can be disregarded.
I am building an elementor site and I am trying to use the script below that I found in the directorist forum, but when placed in the header, it only works when I am on the dashboard page (provided by your plugin). When I am on any other page, this code snippet doesn’t load the image, it just displays a broken image icon instead. Is there a way to adapt the code below so that the avatar image is able to be displayed in the header on any page?
$image_id = get_user_meta( get_the_author_meta( ‘ID’ ), ‘pro_pic’, true ); $image = $image_id ? wp_get_attachment_image_src( $image_id, ‘thumbnail’ ) : ”; $image_url = is_array( $image ) ? $image[0] : $image; echo “<img src='$image_url' alt=''>";
Also, is there a way to input a default image if a user is not logged in?
Thank you for your time,
Ian Harris
- The topic ‘Display Author Avatar in Header’ is closed to new replies.