-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacf_pro_snippets.php
61 lines (56 loc) · 1.89 KB
/
acf_pro_snippets.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php // ACF Repeater ?>
<?php if ( have_rows( 'blocks' ) ) : ?>
<?php while ( have_rows( 'blocks' ) ) : the_row(); ?>
<?php
$header = get_sub_field( 'header' );
$text = get_sub_field( 'text' );
$image = get_sub_field( 'image' );
?>
<?php if ( $header || $text || $image ) : ?>
<!-- Your markup here -->
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php // ACF Flexible Content ?>
<?php if ( have_rows( 'sections' ) ) : ?>
<?php while ( have_rows( 'sections' ) ) : the_row(); ?>
<?php get_template_part( 'blocks/sections/' . get_row_layout() ); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php // ACF Gallery ?>
<?php if ( $images = get_field( 'gallery' ) ) : ?>
<?php foreach ( $images as $image ) : ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>">
<?php endforeach; ?>
<?php endif; ?>
<?php // ACF Theme options ?>
<?php if ( $footer_copyright = get_field( 'footer_copyright', 'option' ) ) : ?>
<div class="copy">
<p><?php echo str_replace( '[year]', date( 'Y' ), $footer_copyright ); ?></p>
</div>
<?php endif; ?>
<?php if ( have_rows( 'social_links', 'option' ) ) : ?>
<ul class="social-links">
<?php while ( have_rows( 'social_links', 'option' ) ) : the_row(); ?>
<?php
$icon_class = get_sub_field( 'icon_class' );
$link = get_sub_field( 'link' );
?>
<?php if ( $icon_class && $link ) : ?>
<li>
<a href="<?php echo esc_url( $link ); ?>" target="_blank">
<span class="icon <?php echo sanitize_html_class( $icon_class ); ?>"></span>
</a>
</li>
<?php endif; ?>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php // ACF Relationship ?>
<?php if ( $posts_objects = get_field( 'posts_objects' ) ) : ?>
<ul>
<?php foreach ( $posts_objects as $post ) : setup_postdata( $post ); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; wp_reset_postdata(); ?>
</ul>
<?php endif; ?>