【发布时间】:2014-06-21 01:25:03
【问题描述】:
ACF Repeater 是一个用于创建自定义字段的 WordPress 插件。我需要获取用逗号分隔的值,但是如何在 while 循环中执行呢?
这是代码:
if( get_field('jobtitles') ) {
echo '<strong>Jobs: </strong>';
while ( have_rows('jobtitles') ) : the_row();
echo '<span>'. get_sub_field('jobtitle') .'</span> ';
endwhile;
}
the_row 遍历主字段 (job titles) 的子字段并获取存储在字段jobtitle 中的值。但它与Medicine Engineering Geography 类似,我需要Medicine, Engineering, Geography。我找到了很多使用foreach 的方法,但没有找到while 循环。
【问题讨论】:
-
您可以考虑将这个问题放在 WordPress 开发者网站上:wordpress.stackexchange.com
-
我做到了,问题被标记为离题。
标签: php wordpress while-loop explode advanced-custom-fields