Support

Account

Forum Replies Created

  • Thanks for your reply John. You’re right, my code was a bit light on content but I added everything I could think of that was relevant. As mentioned I was using the front-page.php template, and my code was not contained within any loops or queries.

    I did, however find the solution. I think it was a combination of misunderstanding on my part, and some ambiguity on the part of ACF + not having super clear documentation.

    There are two things that are used in ACF that sound kind of the same, field group and field (type) group . So I created a field group with the assumption I could just then grab that by referencing the field group name, and have all the data contained therein as a variable. My other field worked fine because I had a field group called ‘gallery’, and within that a field (type) group also called ‘gallery’. So when I called get_field(‘gallery’) it was working because it was grabbing the field type group and not the parent field group itself. I could not find any documentation on accessing the field group directly, so not sure if that’s even possible, so just used this as the solution instead.

  • Never mind I managed to resolve this – here’s my solution if anyone is looking for similar:

    <?php 
    
    $posts = get_field('property_selection');
    
    if( $posts ): ?>
    	<ul>
    	<?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT) ?>
    		<?php $gallery = get_field('property_gallery', $p->ID); ?>
    	    <li><?php echo get_the_title( $p->ID ); ?></li>
    
    	<?php if($gallery) : foreach( $gallery as $item ): // variable must NOT be called $post (IMPORTANT) ?>
    	    <li><?php echo $item['url']; ?> </li>
    	<?php endforeach; endif; ?>
    
    	<?php endforeach; ?>
    	</ul>
    <?php endif; ?>
Viewing 2 posts - 1 through 2 (of 2 total)