forked from stekky81/unipi-child
-
Notifications
You must be signed in to change notification settings - Fork 0
/
category.php
153 lines (122 loc) · 5.47 KB
/
category.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/**
* The template for displaying archive pages
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package unipi
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
get_header();
// bandi + traduzione
if(get_current_blog_id() == 1 && is_category(170) || is_category(171)) {
if ( isset( $_GET['filter'] ) && in_array( $_GET['filter'], ['open', 'in-progress', 'closed'] ) ) {
$filter = $_GET['filter'];
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$dt = new \DateTime('now', new \DateTimeZone('Europe/Rome'));
$dt = $dt->format('Y-m-d H:i:s');
switch ($filter) {
case 'in-progress':
$args = array(
'meta_query' => array(
'relation' => 'AND',
array(
'key'=>'date1',
'compare' => '<',
'value' => $dt
),
array(
'key'=>'date2',
'compare' => '>',
'value' => $dt
),
),
'meta_key'=>'date1',
'paged' => $paged,
'orderby'=>'meta_value',
'order'=>'ASC'
);
break;
case 'closed':
$args = array(
'meta_query' => array(
array(
'key'=>'date2',
'compare' => '<',
'value' => $dt
),
),
'meta_key'=>'date1',
'paged' => $paged,
'orderby'=>'meta_value',
'order'=>'ASC'
);
break;
default:
$args = array(
'meta_query' => array(
array(
'key'=>'date1',
'compare' => '>',
'value' => $dt
),
),
'meta_key'=>'date1',
'paged' => $paged,
'orderby'=>'meta_value',
'order'=>'ASC'
);
break;
}
} else {
$args = array(
'meta_key'=>'date1',
'paged' => $paged,
'orderby'=>'meta_value',
'order'=>'ASC'
);
}
$args = array_merge( $args, $wp_query->query );
query_posts( $args );
}
?>
<div class="wrapper" id="archive-wrapper">
<div class="container py-4" id="content">
<div class="row">
<div class="col-md content-area" id="primary">
<main class="site-main" id="main">
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title bgpantone bgtitle py-1">
<?php single_cat_title(); ?>
</h1>
<?php
the_archive_description( '<div class="taxonomy-description box mb-0">', '</div>' );
?>
</header><!-- .page-header -->
<div class="box">
<?php while ( have_posts() ) : the_post(); ?>
<?php
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'loop-templates/content', get_post_format() );
?>
<?php endwhile; ?>
</div>
<?php else : ?>
<?php get_template_part( 'loop-templates/content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
<!-- The pagination component -->
<?php unipi_pagination(); ?>
</div>
<?php get_template_part( 'sidebar-templates/sidebar', 'right' ); ?>
</div> <!-- .row -->
</div><!-- #content -->
</div><!-- #archive-wrapper -->
<?php get_footer(); ?>