can you loop acf sub field into html tag?

182 Views Asked by At

I am trying to loop my sub field 'sub-header' into a <p> tag so that I can add styles via a class, at the moment it adds the sub field into an empty p tag and misses my class!


<div class="individual-cont <?= $bg && $bg != '#ffffff' ? 'container-bg' : ''?>" style="background-color: <?= $bg ?>">
                <? if($headline = get_sub_field('header')) : ?>
                    <h2 class="individual-cont-title"><?= $headline; ?></h2>
                <? endif; ?>
                <p class="individual-cont-copy"><?= get_sub_field('sub-header'); ?></p>
            </div>

Am I doing something crazily wrong?

Many thanks

0

There are 0 best solutions below