Support

Account

Home Forums General Issues Show content if link field is not filled Reply To: Show content if link field is not filled

  • 
    <?php 
      if (get_sub_field('type') == "Image") {
        ?>
          <div class="full-img">
            <?php
              $link = get_sub_field('link');
              $content = '<img src="'.get_sub_field('image').'">';
              if ($link) {
                $content = '<a href="'.esc_url($link).'">'.$content.'</a>';
              }
              echo $content;
            ?>
            <p class="caption"><?php the_sub_field('caption'); ?></p>
          </div>
        <?php 
      };
    ?>