Repeater 重复器

可无限增加行数,效果如下Advanced Custom Fields PRO Repeater 用法Advanced Custom Fields PRO Repeater 用法

字段设置

Advanced Custom Fields PRO Repeater 用法

//循环输出每行,容器为preview
if( have_rows('preview') ):

// Loop through rows.
while( have_rows('preview') ) : the_row();

// Load sub field value.
$bookname1 = get_sub_field('bookname1');//获取文章ID
$bookpdf = get_sub_field('bookpdf');//获取下载地址
echo '<div class="mulu">';
echo '<div class="mulu-name">';
echo get_the_title($bookname1);//通过ID获取文章标题
echo '</div>';
echo '<div class="mulu-pdf btn">';
echo '<a href="'.$bookpdf.'" target="_blank">目錄預覽</a>';
echo '</div>';
echo '</div>';
// Do something...

// End loop.
endwhile;

// No value.
else :
echo '暫時無預覽';
endif;

返回列表