Wordpress高级自定义字段在一个帖子中为多个外部链接提供外部链接文本

时间:2015-10-12 11:16:19

标签: php wordpress advanced-custom-fields

我在网站上使用ACF插件。让我们说在帖子中我想添加多个外部链接,我希望每个链接都有一个可配置的显示文本而不是永久链接。使用ACF为单个外部链接执行此操作并不难,但我无法弄清楚如何在同一帖子上为多个外部链接执行此操作。

1 个答案:

答案 0 :(得分:0)

你应该看看ACF转发器http://www.advancedcustomfields.com/resources/repeater/

它意味着做你所描述的。 Repeater字段充当数据表,您可以在其中定义列(子字段)并添加无限行。

<?php

//检查转发器字段是否包含数据行 if(have_rows(&#39; repeater_field_name&#39;)):

// loop through the rows of data
while ( have_rows('repeater_field_name') ) : the_row();

    // display a sub field value
    the_sub_field('sub_field_name');

endwhile;

其他:

// no rows found

ENDIF;

&GT;