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

问题描述:

我在网站上使用ACF插件。假设我想在一篇文章中添加多个外部链接,并且我希望每个链接都有一个可配置的显示文字而不是永久链接。使用ACF为单个外部链接做这件事并不困难,但我无法弄清楚如何为同一帖子上的多个外部链接做到这一点。Wordpress高级自定义字段外部链接文本在一个帖子中的多个外部链接

你应该看看ACF中继http://www.advancedcustomfields.com/resources/repeater/

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

<?php 

//检查中继器字段具有数据 行如果(have_rows( 'repeater_field_name')):

// 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;

?>

+0

谢谢。有用! :) – ninjacoder