Answers for "how to display just text if link has no url acf"

0

how to display just text if link has no url acf

<li>
  <?php 
    $text = get_sub_field('list_item');
    $url = get_subfield('item_url');
    if ($url) {
      $text = '<a href="'.$url.'" target="_blank">'.$text.'</a>';
    }
    echo $text;
  ?>
</li>
Posted by: Guest on October-12-2020

Browse Popular Code Answers by Language