WordPress.org

Ready to get started?Download WordPress

Forums

cant get this code to work (2 posts)

  1. posthawk
    Member
    Posted 1 year ago #

    this is what i have but i cant get the image to display

    <a href="<?php the_author_meta( 'user_url' ); ?>"><img class="aligncenter" title="<?php the_author_meta( 'display_name' ); ?>’s Website" alt="Author Webite Link" src="<?php echo get_avatar( get_the_author_meta('ID'), 32 ); ?>"> </a>

    it just gets a broken link and "> in hyperlink text on certain pages

    i know that get_avatar does work, there's just something wrong in the code. everything else works fine, the link, the alignment, the title, everything but the image.

    [ please read: http://codex.wordpress.org/Forum_Welcome#No_Bumping ]

  2. vtxyzzy
    Member
    Posted 1 year ago #

    The problem is that get_avatar() returns a complete img tag, not just a URL. You are getting something like this:

    <a href="http://mysite.com/a_sample_page/"><img class="aligncenter" title="jones’s Website" alt="Author Webite Link" src="<img alt='' src='http://1.gravatar.com/avatar/1cf8f39b7ea0e631f13a28c8d93d0?s=32&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503aca435acc9bb6523536%3Fs%3D32&r=G' class='avatar avatar-32 photo' height='32' width='32' />"> </a>

    See the src="<img alt='' ... />"> part? That is incorrect because get_avatar() is inserting the complete img tag.

Topic Closed

This topic has been closed to new replies.

About this Topic