0
votes

I'm using Owl Carousel to create a carousel gallery of logos. I'm using Advanced Custom Field's repeater feature to grab all of the urls of the logos. Here's the markup for the gallery:

<div id="clients">
   <?php
      $clients = get_field('client_carousel');
      $client_logo = get_field('client_logo');

      if( $clients ) {
    ?>
    <section>
       <div id="owl-clients" class="owl-theme owl-carousel">

       <?php foreach( $clients as $client_logo ): ?>
       <div class="item">
       <img class="featurette-image img-responsive center-block" src="<?php echo $client_logo['url']; ?>" alt="<?php echo $client_logo['alt']; ?>"></div>
       <?php endforeach; ?>

       </div>
   </section>
   <?php } ?>
</div><!--end clients-->

The repeater field name is client_carousel and the field name of the field within it is client_logo.

I have a working demo here. It recognizes the seven logos in the group, but the only thing I can't get is the url for the img src.

1

1 Answers

0
votes

Couple things to note. You're overriding the $client_logo variable, so not sure if that was just an abandoned artifact in the code since it doesn't look like you use it anyhow:

$client_logo = get_field('client_logo');
<?php foreach( $clients as $client_logo ): ?>

Other thing is ACF repeater field allows you to choose the output of the field type "image" - assuming that's what you set for the "url" field. Now, suppose you set "url" as an image, you can then select the output as Image URL instead of the default Image Array if you want the raw URL returned.

enter image description here

Supposing that's how you set it, then it should give you the image url without having ot modify your code:

<?php echo $client_logo['url']; ?>

However, we don't know the architecture of your repeating field and without that knowledge we wouldn't be able to advise further. Update your post and I can update this answer if this info doesn't point you in the right direction.