Home › Forums › Front-end Issues › How to display a google map user profile field in author.php
I’ve searched far and wide and I haven’t been able to find this…
I want to display all of my ACF fields I have inserted into a user’s profile page on/in the author’s archive page (author.php
).
How do I display the author’s google map field (from their profile page) in author.php
?
Thanks.
The only thing different when showing fields on the author page is that you need to specify the correct post_id.
Here is an example getting fields for a user
$user_id = get_the_author_meta('ID');
$post_id = 'user_'.$user_id;
$field_value = get_field('my_field_name', $post_id);
If you used my code exactly then probably not, it was just supposed to be an example.
Try the_field('my_field_name', $post_id);
Did yo change $field_value = get_field('my_field_name')
to the_field('my_field_name');
get_field() get’s the value, the_field() outputs the value.
Also, did you follow the other instructions on http://www.advancedcustomfields.com/resources/google-map/ under required CSS & JS section?
I only followed your instructions. I only swapped themy_field_name
with my own field name.
I was looking at the question about showing user fields on author.php, not at specifically giving you all the code to display a map field. The page that I posted goes into great detail about everything you need to do to display a map field. http://www.advancedcustomfields.com/resources/google-map/
I’ve read that page and haven’t had any luck in implementing it.
The ACF UI stuff is easy but when it comes to using the custom field on the front end that’s where I just can’t get it to work (figured out).
Take a look at this tutorial I found http://www.aliciaramirez.com/2015/02/advanced-custom-fields-google-maps-tutorial/.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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.