Home › Forums › Add-ons › Flexible Content Field › Flex duplicate content › Reply To: Flex duplicate content
Hi @renee
You got multiple style tags because you’ve added it in the while
loop. So, when you have two ‘flex-section’ layouts, the style will be printed twice. If you want to do something like that, I suggest you use the inline CSS code instead. It should be something like this:
<?php if( have_rows('flex-field') ): ?>
<style>
.photo-box {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.fore-image {
background: url(<?php the_sub_field('fore_image'); ?>) no-repeat center;
background-size: contain;
}
</style>
<?php while ( have_rows('flex-field') ) : the_row();?>
<?php if( get_row_layout() == 'flex-section' ); ?>
<div class="photo-box" style="background: url(<?php the_sub_field('hero_image'); ?>) no-repeat center center fixed;"></div>
<div class="fore-image" style="background: url(<?php the_sub_field('fore_image'); ?>) no-repeat center;"></div>
I’m not sure regarding the empty URLs issue. After you tried the code I gave you, could you please share some screenshots of the issue?
Thanks 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.