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”
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