W
W
William Miller2021-08-03 21:47:13
WordPress
William Miller, 2021-08-03 21:47:13

How to get child elements inside ACF custom fields?

I created a group of gallery fields inside it, there are 2 fields with an image, I can’t display these fields in any way, I tried using the_sub_field(), it doesn’t work, please tell me61098f29c4cc1981496289.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy, 2021-08-04
@inefa

Try like this

<?php  $gallery = get_field('profile_gallery'); 
if( $gallery ): ?> 

    <div id="gallery"> 
        <img src="<?php echo esc_url( $gallery['first']['url'] ); ?>" >
        <img src="<?php echo esc_url( $gallery['second']['url'] ); ?>" > 
    </div>  
  
<?php endif; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question