我对.php文件中ACF的每个字段进行样式化有一个问题。
<?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; ?>
我应该如何用HTML来包装我的
get_field("service_title");
get_field (service_description);
And Image字段;
例如:
<p class="text-faded">?php get_field('service_description');?>
</p>
如何以正确的方式用html包装php(而不是用php破坏php代码然后再次中断)
我建议你这样做:
<?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="variable-item"内的所有内容设置样式,然后你可以为其中的任何内容设置样式。