I am relatively new to ACF and I am trying to figure out the power of this tool. I am trying to solve something (that probably is easy for seasoned ACFers) that I cannot seem to find the solution for.
I have a custom post type, “Members”. A member has a featured image and a introduction. I want to grab these two values and show them on the front page, where we can change the member from a dropdown in the back end.
How can I create a dropdown for this and get the data I need?
This week “John Doe” is going to be featured on the front page. I go into the front page in the WordPress control panel and choose him, and update the page. Now John Doe’s image and introduction should show on the front page. Next week I’ll choose “Jane Doe”, and the same happens.
FYI: I am using the Divi page builder, using the Dynamic Tags to retrieve the data from ACF.
I hope that someone can push me in the right direction.
I am assuming here that you are using a post object field to select the member on the front page and that this field is returning a “Post Object”.
// first you get the value of the field on the front page
$member = get_field('featured_member');
// then you get the fields from this members post by supplying the correct post ID
$image = get_field('featured_image', $member->ID);
Viewing 2 posts - 1 through 2 (of 2 total)
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