0
ACFの各フィールドを.phpファイルにスタイリングする際に問題があります。私は私のACF Wordpressスタイリングカスタムフィールド
get_field( 'service_title')をラップするHTMLを置く必要がありますどのように正確に
<?php the_field('service_section_title'); ?>
<?php the_field('service_section_description'); ?>
<a href="<?php the_field('service_section_button_link'); ?>">Learn more</a>
<?php if(have_rows('services')):
while (have_rows('services')) : the_row();
$image = get_field('service_icon'); if(!empty($image)):
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
get_field('service_title');
get_field('service_description');
endwhile; else : endif; ?>
。
get_field( 'service_description');
および画像フィールド。例えば
:ここでは、正しい方法でHTMLとPHPをラップする方法
<p class="text-faded">?php get_field('service_description');?>
</p>
(PHPでPHPコードを破壊し、再び中断していない)
'$ image = get_field( 'service_icon')の後。 if(!empty($ image)): '単に'?> 'をつけて閉じ、' img'タグの後ろに '?php'を追加してもう一度起動します。 –
私は他の "きれいな"方法があると思った。 –
また、画像をエコーすることもできます: 'echo ''。好みの問題。 – HdK