https://www.altcinematic.co.uk/
<?php if(have_rows('films')):
$count = 1; ?>
<section id="content">
<div class="content-section">
<?php while(have_rows('films')): the_row();
if(is_int($count / 2)){
$position = "align-left";
}
else {
$position = "align-right";
}
if($video = get_sub_field('is_this_a_video') == "yes"){
$type = "video";
}
else {
$type = "other";
}
?>
<article class="yellow film-box <?php echo $position . " " . $type; ?>">
<div class="box container-box clear-fix">
<div class="box-right-top">
<div class="img video-wrap">
<div class="iframe-wrap">
<?php the_sub_field('vimeo_link'); ?>
</div><!-- /iframe-wrap -->
</div><!-- /img -->
</div><!-- /box -->
<div class="box-left-top">
<h1><?php the_sub_field('title'); ?></h1>
<?php the_sub_field('intro_text'); ?>
</div>
</div><!-- /box -->
</article>
<?php $count++; endwhile; ?>
</div><!-- /oontent-section -->
</section><!-- /content -->
<?php endif; ?>
The above code was written to pull in some elements which are made with Advanced Custom Fields.
For the first article I am trying to get the video to float right and the text block to float left. The next article follows the pattern but in reverse. So whilst the videos float where I would like, the text blocks do not. The top article should have the text the left, whilst the second article should have the text to the right.
I've written the php this way as in theory it should be really efficient, if the blocks floated correctly.