Home › Forums › Front-end Issues › Displaying fields from a cloned group inside a group › Reply To: Displaying fields from a cloned group inside a group
Hi,
first there seems to be a wrong declaration of the vars in your code:
<?php
//vars
$event = get_field('events');
$event = get_field('address'); // should be $address ?
Then if you want to get the cloned fields, you simply call it by field name to get an array of subfields OR by using the prefix for each field (see your settings screenshot => you enabled this option):
$location = get_field('location');
<div id="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<strong>Address: </strong><span itemprop="streetAddress"><?php echo $location['street_address']; ?></span>, <span itemprop="addressLocality"> <?php echo $location['city']; ?></span>, <span itemprop="addressRegion"><?php echo $location['state']; ?></span>, <span itemprop="addressCountry"><?php echo $location['country']; ?></span>
</div>
Example for getting seperate subfields:
$location_street_address = get_field('location_street_address');
$location_city = get_field('location_city');
$location_state = get_field('location_state');
$location_country = get_field('location_country');
<div id="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<strong>Address: </strong><span itemprop="streetAddress"><?php echo $location_street_address; ?></span>, <span itemprop="addressLocality"> <?php echo $location_city; ?></span>, <span itemprop="addressRegion"><?php echo $location_state; ?></span>, <span itemprop="addressCountry"><?php echo $location_country; ?></span>
</div>
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.