<?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 }
}
?>
How to get multiple custom field on wordpress?
-
29-06-2023 - |
Question
i want to get multiple custom field from wordpress with one line for example. I have field "link","link1","link2","link3","link4" and "link_titull","link_titull1","link_titull2","link_titull3","link_titull4"
I have the code to get just one field and if its not filled its 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 } ?>
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow