Support » Plugin: Custom User Profile Photo » Display avatar outside of the loop

  • Hi !
    Great plugin ! But I need get avatar url image outside of the loop, in head.php
    I can’t find how to do this…
    Can You help me please ?
    Regards,
    Jean David

Viewing 1 replies (of 1 total)
  • Plugin Author Vincent Listrani

    (@vincentlistrani)

    Hello @spix,
    You can do this outside of the loop by using the snippet provided on the main page
    `
    <?php
    // Retrieve The Post’s Author ID
    $user_id = get_the_author_meta(‘ID’);
    // Set the image size. Accepts all registered images sizes and array(int, int)
    $size = ‘thumbnail’;

    // Get the image URL using the author ID and image size params
    $imgURL = get_cupp_meta($user_id, $size);

    // Print the image on the page
    echo ‘<img src=”‘. $imgURL .'” alt=””>’;
    ?>
    `

    The thing you might need to change would be how you set that $user_id property. Depending on which user you’re trying to get, you can use several methods to grab that user. Can you tell me how/why you’re trying to get a user in head.php?

Viewing 1 replies (of 1 total)
  • The topic ‘Display avatar outside of the loop’ is closed to new replies.