
I need some syntax help or something…here is the gist.
I have 4 items in play.
Box 1 Content
Box 1 Image
Box 2 Content
Box 2 Image
What I have the need for is:
If there is no content in one of the boxes, change the class to be full width.
If both boxes have content, they are to be in two columns.
If the box has an image, display the class around the image as well as the image.
If the box doesn’t have an image, don’t display the class surrounding the null-image.
Here is the code I have, but for some reason it still puts in the class for the image. Everything else is working correctly.
<?php if(get_field('box_1') and ('box_2')): ?>
<div class="wdg-box-row">
<?php if(get_field('box_1') and ('box_1_image')): ?>
<?php if(get_field('box_1')) { echo '<div class="wdg-box"><div class="wdg-box-image"><img src="' . get_field('box_1_image') . '" /></div>' . get_field('box_1') . '</div>'; } ?>
<?php else: ?>
<?php if(get_field('box_1')) { echo '<div class="wdg-box">' . get_field('box_1') . '</div>'; } ?>
<?php endif; ?>
<?php if(get_field('box_2') and ('box_2_image')): ?>
<?php if(get_field('box_2')) { echo '<div class="wdg-box"><div class="wdg-box-image"><img src="' . get_field('box_2_image') . '" /></div>' . get_field('box_2') . '</div>'; } ?>
<?php else: ?>
<?php if(get_field('box_2')) { echo '<div class="wdg-box">' . get_field('box_2') . '</div>'; } ?>
<?php endif; ?>
</div>
<?php else: ?>
<div class="wdg-box-row">
<?php if(get_field('box_1') and ('box_1_image')): ?>
<?php if(get_field('box_1')) { echo '<div class="wdg-box-full"><div class="wdg-box-image"><img src="' . get_field('box_1_image') . '" /></div>' . get_field('box_1') . '</div>'; } ?>
<?php else: ?>
<?php if(get_field('box_1')) { echo '<div class="wdg-box-full">' . get_field('box_1') . '</div>'; } ?>
<?php endif; ?>
<?php if(get_field('box_2') and ('box_2_image')): ?>
<?php if(get_field('box_2')) { echo '<div class="wdg-box-full"><div class="wdg-box-image"><img src="' . get_field('box_2_image') . '" /></div>' . get_field('box_2') . '</div>'; } ?>
<?php else: ?>
<?php if(get_field('box_2')) { echo '<div class="wdg-box-full">' . get_field('box_2') . '</div>'; } ?>
<?php endif; ?>
</div>
<?php endif; ?>
I went a different route and this is no longer an issue