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">> <?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">> <?php the_field('link_titul'.$i); ?></a> <?php } } ?>
Comments
Post a Comment