forked from MITLibraries/MITLibraries-news
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadditionalPosts-events.php
80 lines (67 loc) · 1.44 KB
/
additionalPosts-events.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
<script type="text/javascript">
$(document).ready(function() {
$("img.img-responsive").lazyload({
effect : "fadeIn",
effectspeed: 450 ,
failure_limit: 999999
});
});
</script>
<?php
/*
Template Name: Additional Posts Events
*/
$offset = htmlspecialchars(trim($_GET['offset']));
if ($offset == '') {
$offset = 11;
}
$limit = htmlspecialchars(trim($_GET['limit']));
if ($limit == '') {
$limit = 18;
}
?>
<?php
$date = DateTime::createFromFormat('Ymd', get_field('event_date'));
$args = array(
'posts_per_page' => $limit,
'ignore_sticky_posts' => true,
'offset' => 9,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'is_event',
'value' => '1',
'compare' => '=',
),
array(
'key' => 'event_date',
'value' => date("Y-m-d"),
'compare' => '<',
'type' => 'DATE'
),
),
'meta_key' => 'event_date',
'orderby' => array(
'meta_value_num' => 'DESC',
),
);
$the_query = new WP_Query($args);
//removes button start
$ajaxLength = $the_query->post_count;
if ($ajaxLength < $limit){
?>
<script>
$("#another").hide();
</script>
<?php
}
//removes button end
if( $the_query->have_posts() ):
$o = -1;
while ( $the_query->have_posts() ) : $the_query->the_post();
$o++;
renderEventCard($o, $post);
endwhile;
endif;
wp_reset_query(); // Restore global post data stomped by the_post().
?>