php - Hello, I want to get multiple custom field from wordpress with one line -


i want multiple custom field wordpress 1 line example. have field "link","link1","link2","link3","link4" , "link_titull","link_titull1","link_titull2","link_titull3","link_titull4"

i have code 1 field , if not filled showing empty.

<?php $prop_det_url = get_field('link');      if($prop_det_url!=''){ ?>        <a href="<?php echo $prop_det_url; ?>" target="_blank">&gt; <?php the_field('link_titull'); ?></a></p>      <?php } ?> 

you can use loop. see sample code below:

<?php  for( $i=1; $i<=4; $i++){      $prop_det_url = get_field('link'.$i);      if( $prop_det_url != '' ){ ?>      <a href="<?php echo $prop_det_url; ?>" target="_blank">&gt; <?php the_field('link_titul'.$i); ?></a>      <?php }  } ?> 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -