-
Notifications
You must be signed in to change notification settings - Fork 3
/
archive.php
62 lines (50 loc) · 2.27 KB
/
archive.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
<?php
/**
* The template for displaying Archive pages, for native and custom post_types
*
* Used to display archive-type pages if nothing more specific matches a query.
* For example, puts together date-based pages if no date.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* Methods for TimberHelper can be found in the /lib sub-directory
*
* @package wp-softcatala
*/
$templates = array( 'index.twig', 'archive-esdeveniment.twig' );
$context = Timber::get_context();
$post = Timber::query_post(get_option( 'page_for_posts' ));
$context['post'] = $post;
if ( is_category() ) {
$context['categories']['temes'] = Timber::get_terms('category', array('parent' => get_category_id('temes')));
$context['categories']['tipus'] = Timber::get_terms('category', array('parent' => get_category_id('tipus')));
$context['title'] = single_cat_title( '', false );
$context['cat_link'] = get_category_link( get_query_var('cat') );
array_unshift( $templates, 'archive-' . get_query_var( 'cat' ) . '.twig' );
} else { //Any other query asking for date parameters will display just news
$context['categories']['temes'] = Timber::get_terms('category', array('parent' => get_category_id('temes')));
$context['categories']['tipus'] = Timber::get_terms('category', array('parent' => get_category_id('tipus')));
if (is_day()){
$context['title'] = 'Arxiu '.get_the_date( 'j F Y' );
} else if (is_month()){
$context['title'] = 'Arxiu '.get_the_date( 'F Y' );
} else if (is_year()){
$context['title'] = 'Arxiu '.get_the_date( 'Y' );
}
}
$context['links'] = $post->get_field( 'link' );
$context['sidebar_top'] = Timber::get_widgets('sidebar_top');
$context['sidebar_elements'] = array( 'baixades.twig', 'links.twig' );
$context['sidebar_bottom'] = Timber::get_widgets('sidebar_bottom');
//Get the posts depending on the parameters
if( isset( $filter ) ) {
$context['selected_filter'] = $filter;
$args = get_post_query_args( 'esdeveniment', SearchQueryType::FilteredDate, $filterdate );
query_posts($args);
$context['posts'] = Timber::get_posts($args);
} else {
$context['posts'] = Timber::get_posts();
}
$context['pagination'] = Timber::get_pagination();
Timber::render( $templates, $context );
/* Functions */