Support

Account

Home Forums General Issues Echo author image?

Solving

Echo author image?

  • So I have created a field for an author image called cf_author_image. It’s a image object and it’s supposed to return the image url. When I try to echo the image on my author page, it’s just returning the image id (59) instead of the image url. I know that “get_field” is better for images than “get_post_meta”, but how would i go about displaying the image url? Right now I’m using this:

    <?php echo esc_attr( get_the_author_meta( 'cf_author_image', $user->ID ) ); ?>

  • Hi,

    Have you tried to change following radio boxes (attached image) and retest?
    Choosing the “Image URL” radio box should give you the image path.

    You can also get the field values if you have chosen other meta boxes. I recommend you to read documantions.

    Sorry if I got you wrong,

    Regards,

  • Yeah, I have Image URL selected.

    If you want to echo the image url on a regular page or whatever you can do that by simply doing this:
    <?php echo get_field('name_of_field'); ?>
    But if you use this instead:
    <?php echo get_post_meta($post->ID, "name_of_field", true); ?>
    … You don’t get the image url, then you get the image id.

    It seems like you can’t obtain the image url by calling “get_the_author_meta”. Is there another way? Something like “get_the_author_fields”

    • Elliot

    • October 28, 2013 at 4:03 pm

    Hi @cashless

    Please read the docs on how to load data from a user:
    http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-user/

    WP contains functions to load the post author’s ID. It should be easy for you to find the ID, then load the image via get_field.

    Thanks
    E

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.