我想从wordpress获得多个自定义字段,例如一行。我有字段"链接"," link1"," link2"," link3"," link4"和" link_titull"," link_titull1"," link_titull2"," link_titull3"," link_titull4"
我有代码只能获得一个字段,如果没有填充它显示为空。
<?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 } ?>
答案 0 :(得分:0)
<?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 }
}
?>