12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on May 13, 2022

Show ACF User Field Data on CPT Archives in WordPress

Sridhar Katakam

This members-only tutorial provides the steps to add a User-type of custom field using Advanced Custom Fields for a Custom Post Type and output the linked user's display name, avatar/custom image, bio description and a link to that posts authored by that user for each CPT item on the CPT archive.

Step 1

Create a ACF field group having a User-type of field named say user.

Leave the Return Format as User Array.

Set the group to appear for your CPT (staff in this example).

Step 2

Edit your CPT items and select a user for each.

Step 3

Time to define some custom functions that returns

  1. the specified key from the user field's returned array
  2. URL of the avatar/custom image from the ID of the selected user for the post (CPT item, in this case)

Install and activate a code snippets plugin like WPCodeBox.

Add the following PHP code on the frontend:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $599 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right