0
我對高級自定義字段使用彈性內容附加組件,並且無法格式化我的模板代碼中的簡單按鈕鏈接。WP:高級自定義字段 - 靈活的內容鏈接格式
通常我會用這樣的事情...
<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;
?>
有什麼建議嗎?在此先感謝