我已经创建了一个从ACF转发器字段获取信息的快捷码。。。
function display_websites_shortcode() {
ob_start();
// check if the repeater field has rows of data
if( have_rows(\'streaming\') ):
while ( have_rows(\'streaming\') ) : the_row();
// Your loop code
echo \'<a href="\' . the_sub_field(\'website_url\') . \'" >\' . the_sub_field(\'website_source\') . \'</a>\';
endwhile;
else :
// no rows found
echo \'<p>No Websites Available</p>\';
endif;
return ob_get_clean();
}
add_shortcode( \'display_websites\', \'display_websites_shortcode\' );
输出/循环有效,但内容在HTML之外。所以,与其这样。。。<a href="http://google.com">Google</a>
我们得到这个。。。http://google.comGoogle
我还有其他使用类似代码的短代码,我就是搞不懂这一点。我查看了其他有类似问题的帖子,但没有什么突出的地方