【发布时间】:2015-03-22 23:36:41
【问题描述】:
我目前有一个简单的 html 列表。我想要的是重复这个列表项,每个重复的元素都有一个变量,每次重复时都会增加一个。
我在上述列表项中包含的 php 调用来自 WordPress 上的高级自定义字段插件。我要更改的变量是这些 php 调用中的数字。
<ul>
<li>
<?php the_field('vendor_1_name'); ?> <!--the number is the variable that i want to increase by one with each repition-->
<a href="http://<?php the_field('vendor_1_url'); ?>" target="_blank"/>
<?php the_field('vendor_1_url'); ?>
</a>
</li>
</ul>
我知道如何使用数组来做到这一点,但我很想听听其他方法来做这样的事情。谢谢!
【问题讨论】:
-
应该迭代多少次?
标签: php html wordpress advanced-custom-fields