items.php 1.44 KB
Newer Older
Benthe Kuijpers's avatar
Benthe Kuijpers committed
1
2
<?php
$layout = get_sub_field('layout');
3
4
5
$background = get_sub_field('background');
$total_items = count(get_sub_field('items'));
$amount = ($total_items > 3) ? 'max' : 'min';
Benthe Kuijpers's avatar
Benthe Kuijpers committed
6
?>
7
<div class="content-row items-row items-row--<?php echo $layout; ?> content-row--<?php echo $background; ?> items-row--<?php echo $amount; ?>">
Benthe Kuijpers's avatar
Benthe Kuijpers committed
8
9
10
11
12
13
14
15
16
	<div class="container">
		<h3><?php the_sub_field('title'); ?></h3>
		<?php
		if (have_rows('items')) : ?>
			<div class="grid grid--medium">
				<?php while (have_rows('items')) : the_row(); ?>
					<div class="item">
						<?php
						$image = get_sub_field('img');
Benthe Kuijpers's avatar
Benthe Kuijpers committed
17
						$crop = get_sub_field('img_crop');
Benthe Kuijpers's avatar
Benthe Kuijpers committed
18
						if( $image ) {
Benthe Kuijpers's avatar
Benthe Kuijpers committed
19
							echo '<div class="img img--' . $crop . '">' . wp_get_attachment_image( $image, 'medium' ) . '</div>';
Benthe Kuijpers's avatar
Benthe Kuijpers committed
20
21
22
23
						} ?>
						<div class="item__content">
							<h3><?php the_sub_field('title'); ?></h3>
							<?php the_sub_field('description');
24

Benthe Kuijpers's avatar
Benthe Kuijpers committed
25
							$link = get_sub_field('text_link');
26
27
28
29
30
31
32
33
34
35
							if( $link ):
							  $link_url = $link['url'];
							  $link_title = $link['title'];
							  $link_target = $link['target'] ? $link['target'] : '_self';
							  echo '<a href="' . esc_url( $link_url ) . '" target="' . esc_attr( $link_target ) . '" class="text-link ';
							  if ($link_target === '_blank') {
							  	echo 'text-link--external';
							  }
							  echo '">' . esc_html( $link_title ) . '</a>';
							endif; ?>
Benthe Kuijpers's avatar
Benthe Kuijpers committed
36
37
38
39
40
41
42
						</div>
					</div>
				<?php endwhile; ?>
			</div>
		<?php endif; ?>
	</div>
</div>