-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate-loop.php
More file actions
84 lines (66 loc) · 2.13 KB
/
template-loop.php
File metadata and controls
84 lines (66 loc) · 2.13 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
//----------------------------------------------------------------
// ACF ORIGIN ROWS & COLUMNS
// For use with the excellent ACF plugin by Elliot Condon.
// For information on ACF see www.advancedcustomfields.com
//
// https://github.com/davejfox/ACF-Origin-Grid
//
// By Dave J. Fox - twitter.com/davejfox || github.com/davejfox
//----------------------------------------------------------------
// Place this function in your functions.php file.
function columnClasses() {
/*
These are the names of the default breakpoints in Origin.
If you add more breakpoints in the CSS, you can add them
here too.
*/
$breakpoints = array("large", "medium", "small", "xsmall");
foreach ($breakpoints as &$breakpoint) {
$columnNumber = get_sub_field("size_" . $breakpoint);
echo " " . $breakpoint . "-" . $columnNumber;
if( get_sub_field("centering_uncentering") ):
if( have_rows("center_uncenter") ):
while( have_rows("center_uncenter") ): the_row();
$breakpointCenterUncenter = get_sub_field("cu_" . $breakpoint);
if ($breakpointCenterUncenter != "Regular Position") {
echo " " . $breakpoint . "-" . $breakpointCenterUncenter;
}
endwhile;
endif;
endif;
if( get_sub_field("column_push_pull") ):
if( have_rows("push_pull") ):
while( have_rows("push_pull") ): the_row();
$breakpointPushPull = get_sub_field("pp_" . $breakpoint);
if ($breakpointPushPull != "Regular Position") {
echo " " . $breakpoint . "-" . $breakpointPushPull;
}
endwhile;
endif;
endif;
}
}
// End of function.
?>
<?php
// Below is an example of how this can be used. You can place the loops of your own flexible content where indicated.
?>
<section>
<?php
if( have_rows("row") ):
while ( have_rows("row") ) : the_row(); ?>
<div class="row">
<?php if( have_rows("column") ): ?>
<?php while( have_rows("column") ): the_row(); ?>
<div class="column<?php columnClasses(); ?>">
<p>The loop for your flexible content for each column can go here.</p>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php
endwhile;
endif;
?>
</section>