A simple check should do:
$location = get_field('location');
if($location) :
echo '<p>acf stuff' . $location . '</p>';
endif;
Is there another field on the same page/post with the same field name? I’ve had this happen to me before, and the second field instance will override the first.
Have you tried the latest ACF version? It supports pagination on repeater fields to help with load time.
Hi Steven,
The shortcode only returns simple text-based values, so if the agent_picture
returns an array of image info, then the shortcode will not be ideal for your use case. However, you can probably use it to display an agent’s name, email, and phone, assuming that all those values are stored in text, email, and tel type fields.
Anyway, I think you are getting the shortcode confused with code that would happen in a code loop that goes through the homes. The logic would look something like this for your use case:
foreach home CPT as Home
Display Home info
Get all Agents assigned to Home
foreach Agents as Agent
Display Agent info (this is where you can use the shortcode)
endforeach loop
endforeach loop
Thank you for your response! I posted a reply to you for bug #2, but I’m not seeing it anymore. I will submit via the link you provided.
Hi John! Thanks for your response. For bug 2, there are actually 2 separate clone fields that clone the same field group. In my example, Header (component field group) and Footer (component field group) are 2 separate clone fields. I enabled prefix for both of them and that was where I saw the bug. Enabling prefix on the labels and field names gave me this setup:
header_content_type
header_content
header_code
footer_content_type
footer_content
footer_code
The base field group for the component has these fields without the prefixes:
content_type
content
code
I see what you mean John. Thanks for the insight.
I use clone fields heavily to make managing component blocks and their fields easier. There are some things about the Group setting that I dislike similar to alpipego. Since the seamless fields have conditional displays within that field group, is it possible to have a “nested” set of display fields for seamless fields too that are honored at the parent-level? For example:
Background Settings Field Group
– Background Type (radio)
— Option 1: None
— Option 2: Color
— Option 3: Image
– Background Color (color picker; displays when “Option 2: Color” is selected)
– Background Image (image; displays when “Option 3: Image” is selected)
Then in a flexible field, there is a group of flexible fields that reuses the background settings field group like so.
– Content (WYSIWYG)
– Media Type (radio)
— Option 1: Image
— Option 2: Form
– Image (image; displays when “Option 1: Image” is selected)
– Form (post object; displays when “Option 2: Form” is selected)
– Form Background (clone; displays when “Option 2: Form” is selected) <– Honor this conditional display in parent flexible fields, and then honor conditional display in fields of field group
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.