-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive-event.php
96 lines (73 loc) · 1.99 KB
/
archive-event.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
<?php
/**
* The template for displaying archive pages
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Systemorph_2018
* @since 1.0
* @version 1.0
*/
get_header(); ?>
<div class="wrap">
<?php if ( have_posts() ) : ?>
<header class="page-header">
<?php
$postType = get_archive_post_type();
echo '<h1 class="page-title">' . $postType . '</h1> ';
echo '<p class="page-description">' . get_the_post_type_description() . '</p> ';
?>
</header><!-- .page-header -->
<?php endif; ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
$limit = 5;
$terms = get_terms( 'event-timeline', array(
'orderby' => 'name',
'order' => 'DESC',
'hide_empty' => 1
) );
foreach( $terms as $term ) {
$args = array(
'posts_per_page' => $limit,
'post_status' => 'publish',
'post_type' => 'event',
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => $term->taxonomy,
'field' => 'slug',
'terms' => $term->slug
)
)
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
?>
<?php
echo '<section class="term ' . $term->slug . '">';
echo '<header class="taxonomy-term-title">';
echo '<h2>' . $term->name . '</h2>';
if ($query->found_posts > $limit) {
echo '<a class="view-all" href="' . get_term_link( $term->term_id ) . '">View all</a>';
}
echo '</header>';
while ( $query->have_posts() ) :
$query->the_post();
get_template_part( 'template-parts/post/content', get_post_type() );
endwhile;
echo '</section>';
else :
get_template_part( 'template-parts/post/content', 'none' );
endif;
wp_reset_postdata();
}
?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .wrap -->
<?php
get_footer();