-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshortcodes.php
More file actions
123 lines (105 loc) · 3.05 KB
/
shortcodes.php
File metadata and controls
123 lines (105 loc) · 3.05 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
<?php
/**
* Returns a person list
**/
function ucf_people_list_shortcode( $atts, $content='' ) {
$atts = shortcode_atts(
array(
'people_group' => null,
'category' => null,
'positions' => false,
'limit' => -1
),
$atts
);
$args = array(
'post_type' => 'person',
'posts_per_page' => (int)$atts['limit'],
'meta_key' => 'person_last_name',
'order' => 'ASC',
'orderby' => 'meta_value'
);
if ( $atts['category'] ) {
$args['category_name'] = $atts['category'];
}
if ( $atts['people_group'] ) {
$args['tax_query'] = array(
array(
'taxonomy' => 'people_group',
'field' => 'slug',
'terms' => $atts['people_group']
)
);
}
// Create iterator for layout here.
$i = 0;
ob_start();
if ( $atts['positions'] ) {
$chair_id = get_theme_mod_or_default( 'board_chair' );
$vice_chair_id = get_theme_mod_or_default( 'board_vice_chair' );
$exclude = array();
if ( !empty( $chair_id ) ) {
$chair = get_post( $chair_id );
$chair = UCF_People_PostType::append_metadata( $chair );
$exclude[] = $chair->ID;
}
if ( !empty( $vice_chair_id ) ) {
$vice_chair = get_post( $vice_chair_id );
$vice_chair = UCF_People_PostType::append_metadata( $vice_chair );
$exclude[] = $vice_chair->ID;
}
if ( count( $exclude ) > 0 ) {
$args['post__not_in'] = $exclude;
}
}
$people = get_posts( $args );
$count = count( $people ) - 1;
if ( isset( $chair ) ) :
?>
<?php if ( $i % 3 === 0 ) : ?><div class="row"><?php endif; ?>
<div class="col-md-4 col-sm-6">
<?php echo get_person_markup( $chair, 'Board Chair' ); ?>
</div>
<?php if ( $i % 3 === 2 ) : ?></div><?php endif; $i++; $count++; ?>
<?php
endif;
if ( isset( $vice_chair ) ) :
?>
<?php if ( $i % 3 === 0 ) : ?><div class="row"><?php endif; ?>
<div class="col-md-4 col-sm-6">
<?php echo get_person_markup( $vice_chair, 'Board Vice Chair' ); ?>
</div>
<?php if ( $i % 3 === 2 ) : ?></div><?php endif; $i++; $count++; ?>
<?php
endif;
foreach( $people as $person ) :
$person = UCF_People_PostType::append_metadata( $person );
?>
<?php if ( $i % 3 === 0 ) : ?><div class="row"><?php endif; ?>
<div class="col-md-4 col-sm-6">
<?php echo get_person_markup( $person ); ?>
</div>
<?php if ( $i % 3 === 2 || $i === $count ) : ?></div><?php endif; $i++; ?>
<?php
endforeach;
return ob_get_clean();
}
add_shortcode( 'people-list', 'ucf_people_list_shortcode' );
function ucf_people_group_charter_list_shortcode( $atts, $content="" ) {
$none_term = term_exists( 'None', 'people_group' );
$terms = get_terms( array(
'taxonomy' => 'people_group',
'exclude' => array( $none_term )
) );
ob_start();
?>
<ul class="list-unstyled document-list">
<?php foreach( $terms as $term ) : $charter = get_field( 'people_group_charter', 'people_group_' . $term->term_id ); ?>
<li><a class="document" href=<?php echo $charter; ?>><?php echo $term->name; ?> Committee Charter</a></li>
<?php endforeach; ?>
</ul>
<?php
return ob_get_clean();
}
add_shortcode( 'charter-list', 'ucf_people_group_charter_list_shortcode' );
?>