• Resolved jimario

    (@jimario)


    Hi,

    After installing your plugin, I uploaded photo for my Avatar while editing my profile. That worked fine, the photo shows up correctly. I then placed your template code on my author.php template file. But when visiting the author page, only the default avatar shows up. This is the code I am using that I found from other posts in your forum:

    <?php echo do_shortcode(‘[avatar user=”‘.get_the_author_meta(‘ID’).'”]’); ?>

    <?php echo get_wp_user_avatar(get_the_author_meta(‘ID’), 96); ?>

    Neither one of these works. Please help.

    https://wordpress.org/plugins/wp-user-avatar/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jimario

    (@jimario)

    Ok, I just realized something. Avatars with photos will show up when the url is something like this: http://www.site.com/author/m However, the default avatar will show up on urls like this http://www.site.com/?author=10 which happens to be the same profile page as site.com/author/m

    So it seems that WP User Avatar works on pretty permalinks rather than the regular ones. Is there a way to get it to work on regular permalinks?

    On an author page you should use this:

    <?php
      $user = get_user_by('slug', $author_name);
      echo get_wp_user_avatar($user->ID, 96);
    ?>

    For reference, you could also check out the installation page in addition to forum posts.

    Thread Starter jimario

    (@jimario)

    Thanks. I just noticed your response. I went ahead and tried your code but I’m still getting the same result.

    http://choochooclan.com/surrogate/?author=10
    vs
    http://choochooclan.com/surrogate/author/m/

    I’m not sure why you would want to use the http://choochooclan.com/surrogate/?author=10 format, but if you want to cover your bases you can use this:

    <?php
      $user = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
      echo get_wp_user_avatar($user->ID, 96);
    ?>
    Thread Starter jimario

    (@jimario)

    well, i don’t want to do that but I’m using another plugin which lists users and allows me to link back to the author page. However, I can’t control how it links back and unfortunately it’s using the WP link method.

    The code you just posted worked like a charm. Thank you so much.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Default Avatar instead of real avatar on Author.php pages’ is closed to new replies.