我正在为高级自定义字段使用灵活内容插件,并且在我的模板代码中格式化一个简单的按钮链接时遇到了问题。
通常我会使用这样的东西......
<a class="button" href="<?php the_field('button-link'); ?>"><?php the_field('button-text'); ?></a>
...输出以下html:
<a class="button" href="http://url.com/the-link">The Text</a>
但我不知道如何调整它以在我的灵活内容模板中工作:
<?php
if( have_rows('sidebar-content') ):
while ( have_rows('sidebar-content') ) : the_row();
if( get_row_layout() == 'text-content' ):
echo '<div class="sidebar-text-content">';
the_sub_field('flexible-text-content');
echo '</div>';
elseif( get_row_layout() == 'quote' ):
echo '<blockquote>';
the_sub_field('quote-text');
echo '<span class="quote-source">';
the_sub_field('quote-source');
echo '</span>';
echo '</blockquote>';
elseif( get_row_layout() == 'images' ):
$image = get_sub_field('image');
echo '<img src="' . $image['sizes']['large'] . '" alt="' . $image['alt'] . '" />';
endif;
endwhile;
endif;
?>
有什么建议么?提前致谢