-
Notifications
You must be signed in to change notification settings - Fork 0
/
list-staff-shortcode.php
107 lines (89 loc) · 2.57 KB
/
list-staff-shortcode.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
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
<?php
/*
Plugin Name: List Staff Shortcode
Description: Lightly modified version of List Pages Shortcode to just get staff by category.
Author: Bill Hunt
Version: 1.0.0
Author URI: http://www.krues8dr.com
*/
// [bartag foo="foo-value"]
function stafflist_function( $atts ) {
global $post;
$content = '';
$args = array(
'meta_query' => array(
array(
'key' => 'staff-group',
'value' => $atts['group'],
'compare' => 'LIKE'
)
),
'post_type' => 'page',
'order' => 'ASC',
'orderby' => 'menu_order',
'nopaging' => true
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
$content .= '<ul class="sunlightStaff">';
while ( $the_query->have_posts() ) {
$the_query->the_post();
$meta = get_post_meta($post->ID);
$content .= '<li><a href="' . get_the_permalink() .'">
<span class="imgWrapper">'. get_the_post_thumbnail() .'</span>
<span class="name">'. get_the_title() .'</span>
<span class="staffTitle">'. $meta['staff-role'][0] .'</span></a></li>';
}
$content .= '</ul>';
/* Restore original Post Data */
} else {
// no posts found
}
wp_reset_postdata();
return $content;
}
add_shortcode( 'stafflist', 'stafflist_function' );
function sfrex_function() {
$args = array(
'meta_query' => array(
array(
'key' => 'staff-group',
'value' => 'staff',
'compare' => 'LIKE'
)
),
'post_type' => 'page',
'order' => 'ASC',
'orderby' => 'menu_order',
'nopaging' => true
);
// The Query
$the_query = new WP_Query( $args );
$content = '';
$count = 0;
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
$content .= '<div class="rex-people" style="display:none" id="person-' . $count .'">
<span class="img">'. get_the_post_thumbnail() .'</span>
<span class="name">Today\'s Cleanosaur:<br/>'. get_the_title() .'</span>
</div>';
$count++;
}
}
$content .= "<script>
(function() {
var people_count = $('.rex-people').size();
var today = new Date();
var day_count = Math.floor(today / (24 * 60 * 60 * 1000));
var person_day = day_count % people_count;
$('#person-' + person_day).show();
})();
</script>";
return $content;
}
add_shortcode( 'sfrex', 'sfrex_function' );
?>