• Hello,
    I would have the idea to show the users avatar picture on a post template according to the custom field value for that post.

    to show the avatar knowing the user email i would use this code;

    <?php echo get_avatar('[email protected]' ); ?>

    to display my email: [email protected] I entered in the custom field named “email” i would use this code;

    <?php
    global $wp_query;
    $postid = $wp_query->post->ID;
    echo get_post_meta($postid, 'email', true);
    wp_reset_query();
    ?>

    How to connect somehow this two codes to display the avatar image according to the email from the custom field?

    Thanks

Viewing 1 replies (of 1 total)
  • I assume your two snippets will work. If so, then this may be what you want:

    <?php
    global $wp_query;
    $postid = $wp_query->post->ID;
    $email = get_post_meta($postid, 'email', true);
    echo get_avatar( $email );
    wp_reset_query();
    ?>
Viewing 1 replies (of 1 total)

The topic ‘Display avatar picture using custom fields’ is closed to new replies.