Home Forums General Issues Alternative url not working


Alternative url not working

  • I’m trying to display an alternative url for each of my gallery images, this custom field is an attachment displayed on all image formats.

    The problem is that the field is return “null” instead of the url. What could it be?

     $images = get_field('slider_principal_banners', 4);
      $link = get_field('link_alternativo');
    	if( $images ): ?>
    	    <div class="slider-principal swiper-container"> 
        		<div class="swiper-wrapper"> 
    	            <?php foreach( $images as $image ): ?>
    	                <div class="swiper-slide">
            		  <a href="<?php echo $link; ?>">
    	                    <img src="<?php echo $image['url']; ?>" alt="<?php echo 
                                   $image['alt']; ?>">
    	            <?php endforeach; ?>
    	       <div class="swiper-pagination"></div>
    	       <div class="swiper-prev"></div>
    	       <div class="swiper-next"></div>
    	<?php endif; ?>
  • Does it shift anything if you adjust $images = get_field( 'slider_principal_banners', 4 ); to $images = get_field( 'slider_principal_banners' );?

    Neither the images nor the URL field will work for me otherwise on my end otherwise. If you’d like to set a max/min of four images, you could set that within the ACF field settings themselves rather than that line.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Alternative url not working’ is closed to new replies.