How to display an acf field from a user profile?

10,890

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 );
Share:
10,890
M1lls
Author by

M1lls

Updated on June 05, 2022

Comments

  • M1lls
    M1lls almost 2 years

    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>