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コードを破壊し、再び中断していない)

+0

'$ image = get_field( 'service_icon')の後。 if(!empty($ image)): '単に'?> 'をつけて閉じ、' img'タグの後ろに '?php'を追加してもう一度起動します。 –

+0

私は他の "きれいな"方法があると思った。 –

+0

また、画像をエコーすることもできます: 'echo '' . $image['alt'] . ''。好みの問題。 – HdK

答えて

0

は、私はあなたがお勧めです:

<?php if (have_rows('repeater')): ?> 
    <?php while (have_rows('repeater')): the_row(); ?> 

    <?php 
    $variable = get_sub_field('variable'); 
    ?> 

    <div class="repeater-item"> 
     <div class="variable-item"> 
      <?php echo $variable; ?> 
     </div> 
    </div> 
    <?php endwhile; ?> 
<?php endif; ?> 

これはDIV CLASS =「可変項目」内部スタイルすべてですそして、あなたがそこに何かをスタイルすることができた後、あなたがすべて。

関連する問題