Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display an acf field from a user profile?

I currently have an advanced custom field setup in the user's profile with a field name of author_title. This would display what the user does at the company blog.

acf user field

I currently have the following working but the title only updates for first user and all users get that title instead of being able to use their own.

Updated

<?php $current_user = wp_get_current_user(); ?>  
<h3><?php the_field('author_title', 'user_' . $current_user->ID); ?></h3>
like image 495
M1lls Avatar asked Dec 24 '22 03:12

M1lls


1 Answers

Try to get user ID in another way.

Now you get ID for currently logged in user so it shows the same field everywhere. I assume you need show that filed for author posts so:

$author_id = get_the_author_meta('ID');
$author_field = get_field('author_title', 'user_'. $author_id );
like image 112
dkruchok Avatar answered Feb 19 '23 16:02

dkruchok