出于某种原因,我的循环将只显示转发器的第一行。如何让循环为已添加的所有行创建链接?
function related_pages_shortcode2() {
if( have_rows('related_pages') ):
while( have_rows('related_pages') ): the_row();
$type = get_sub_field('type');
$name = get_sub_field('name');
$link = get_sub_field('url');
$related_page = '<strong>' . $type . ': </strong>' . '<a href="' . $link . '">' . $name . '</a>';
return $related_page;
endwhile;
else :
endif;
}
add_shortcode( 'related_pages2', 'related_pages_shortcode2' );