-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage-team.php
More file actions
144 lines (98 loc) · 5.88 KB
/
page-team.php
File metadata and controls
144 lines (98 loc) · 5.88 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* Template Name: Team
*/
get_header();
function sort_by_last_name($a, $b) {
$a_name = explode( ' ', $a->post_title );
$b_name = explode( ' ', $b->post_title );
$a_last_name = $a_name[ (count($a_name) - 1) ];
$b_last_name = $b_name[ (count($b_name) - 1) ];
if ( $a_last_name == $b_last_name ) {
return 0;
}
return ( $a_last_name < $b_last_name ) ? -1 : 1;
}
?>
<div class="site-content">
<article <?php post_class('wrap'); ?>>
<section class="section">
<div class="flex has-sidebar u-container">
<?php get_template_part( 'partials/menu-ui' ); ?>
<div class="sidebar-masthead section__sidebar flex__item">
<?php get_template_part( 'partials/masthead' ); ?>
</div>
<div class="section__content flex__item">
<div class="page-header">
<h1 class="page-title h2 u-mt-pull">
<span class="u-color-dark-gray">
<?php the_title(); ?>
</span>
</h1>
</div>
<ul class="list page-anchors">
<?php
while ( have_rows( 'visible_roles' ) ) : the_row();
$role = get_sub_field('role'); ?>
<li class="list__item">
<a href="#<?php echo $role->slug; ?>" class="u-color-hover-purple"><?php echo $role->name; ?></a>
</li>
<?php endwhile; ?>
</ul>
</div> <!-- .section__content -->
</div><!-- .u-container -->
</section>
<section class="section">
<div class="flex u-container">
<div class="section__content u-width-12 flex__item">
<?php while ( have_rows( 'visible_roles' ) ) : the_row();
$role = get_sub_field('role');
$team_members = new WP_Query(array(
'post_type' => 'team_member',
'posts_per_page' => 500,
'orderby' => 'title',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'team_role',
'field' => 'slug',
'terms' => $role->slug
)
)
));
if ( $team_members->have_posts() ) :
$team_member_posts = $team_members->posts;
$order_by = get_sub_field('order_by');
if ( 'last_name' === $order_by ) {
usort( $team_member_posts, 'sort_by_last_name' );
} ?>
<div id="<?php echo $role->slug; ?>">
<h2 class="h4 u-pt-4"><?php echo $role->name; ?></h2>
<div class="u-clearfix">
<?php foreach ( $team_member_posts as $post ) : setup_postdata( $post ); ?>
<?php
$display_as = get_sub_field('display_as');
if ( 'text' === $display_as ) : ?>
<article <?php post_class( 'u-span-4 u-mt-1 preview' ); ?> >
<?php get_template_part( 'partials/content-preview', 'team_member-text' ); ?>
</article>
<?php elseif ( 'profile_card' === $display_as ) : ?>
<article <?php post_class( 'u-span-3 u-mt-2 preview' ); ?> >
<?php get_template_part( 'partials/content-preview', 'team_member_no_image' ); ?>
</article>
<?php else : ?>
<article <?php post_class( 'u-span-3 u-mt-2 preview' ); ?> >
<?php get_template_part( 'partials/content-preview', 'team_member' ); ?>
</article>
<?php endif; ?>
<?php endforeach; wp_reset_postdata(); ?>
</div>
</div>
<?php endif; ?>
<?php endwhile; ?>
</div> <!-- .section__content -->
</div><!-- .u-container -->
</section>
</article>
</div>
<?php get_footer();