This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive-meet.php
64 lines (62 loc) · 1.83 KB
/
archive-meet.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
<?php
get_template_part('partials/global/html-header');
get_template_part('partials/global/header');
$posts_count = new WP_Query($query_string . "&posts_per_page=-1");
$posts_count = $posts_count->found_posts;
$posts_per_page = get_option('posts_per_page');
$current_page = get_query_var("paged") ? get_query_var("paged") : 1;
$meet_query = new WP_Query(array(
"post_type" => "meet",
"orderby" => "meta_value",
"order" => "DESC",
"paged" => $current_page,
"posts_per_page" => $posts_per_page,
"meta_key" => "meet_end_time"
));
?>
<main class="main" id="content" role="main">
<?php if($meet_query->have_posts()): ?>
<div class="grid">
<?php
while($meet_query->have_posts()):
$meet_query->the_post();
get_template_part('partials/meet/card');
endwhile;
?>
</div>
<?php endif; ?>
<nav class="pagination">
<ul class="pagination__list">
<?php
$iteration = 0;
for($i = $meet_query->max_num_pages; $i > 0; $i--):
$number_start = $posts_count - ($posts_per_page * $iteration);
$number_end = ($number_start - $posts_per_page + 1) > 1 ? ($number_start - $posts_per_page + 1) : 1;
?>
<li class="pagination__item">
<a href="?paged=<?php echo $iteration + 1; ?>" class="pagination__link<?php if($iteration + 1 == $current_page) { echo ' pagination__link--current'; } ?>">
<?php
if($number_start != $number_end):
?>
Meets #<?php echo $number_start; ?>–<?php echo $number_end; ?>
<?php
else:
?>
Meet #<?php echo $number_start; ?>
<?php
endif;
?>
</a>
</li>
<?php
$iteration++;
endfor;
// print_r($meet_query->max_num_pages);
?>
</ul>
</nav>
</main>
<?php
get_template_part('partials/global/footer');
get_template_part('partials/global/html-footer');
?>