-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive-akce.php
118 lines (102 loc) · 3.88 KB
/
archive-akce.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
<?php
/**
* The template for displaying Archive pages.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package Instruktoři
*/
get_header(); ?>
<div class="row">
<section id="primary" class="content-area col-xs-12">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<header>
<h1 class="page-title">
<?php
if ( function_exists( 'ot_get_option' ) ) {
echo ot_get_option( 'archive_akce_nadpis', 'Kalendář instruktorských akcí' );
}
?>
</h1>
</header>
<?php
$dnesni_datum = Date( 'U' );
$args = array(
'post_type' => 'akce',
'numberposts' => '-1',
'meta_key' => 'akce_from',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'akce_from',
'value' => $dnesni_datum,
'type' => 'numeric',
'compare' => '>=',
),
),
);
$lastposts = get_posts( $args );
echo '<div class="row">';
foreach ( $lastposts as $post ) :
setup_postdata( $post );
$akce_from_timestamp = get_post_meta( $post->ID, 'akce_from', true );
$akce_to_timestamp = get_post_meta( $post->ID, 'akce_to', true );
$akce_url = get_post_meta( $post->ID, 'akce_url', true );
echo '<div class="col-sm-4 col-lg-3">';
echo '<div class="akce-box">';
echo '<div class="post-archive-thumbnail post-thumbnail thumbnail-type-' . get_post_type( $post->ID ) . ' hidden-xs">';
if(!empty($akce_url)){
echo '<a href="' . $akce_url . '" title="' . get_the_title() . '">';
} else {
echo '<a href="' . get_permalink() . '" title="' . get_the_title() . '">';
}
if ( has_post_thumbnail() ) {
$custom = get_post_custom();
$custom = get_post_meta( $custom['_thumbnail_id'][0], '_wp_attached_file', true );
$uploads = wp_upload_dir();
echo '<img src="' . $uploads['baseurl'] . '/' . $custom . '" alt="' . get_the_title() . '"/>';
} else {
echo '<img src="' . get_template_directory_uri() . '/images/no-thumbnail.png" alt="' . get_the_title() . '"/>';
}
echo '</a></div>'; // .post-archive-thumbnail apod.
echo '<div class="akce-padding">';
if(!empty($akce_url)){
the_title('<h3><a href="' . $akce_url . '">', '</a></h3>');
} else {
the_title( '<h3><a href="' . get_permalink() . '">', '</a></h3>' );
}
if ( ! empty( $akce_from_timestamp ) and empty( $akce_to_timestamp ) ) {
echo date( 'd.m.Y', $akce_from_timestamp );
} elseif ( ! empty( $akce_from_timestamp ) and ! empty( $akce_to_timestamp ) ) {
echo date( 'd.m.', $akce_from_timestamp ) . ' - ' . date( 'd.m.Y', $akce_to_timestamp );
}
the_excerpt();
echo '</div>';
echo '<div class="akce-links">';
echo '<div class="row">';
echo '<div class="col-sm-6"><div class="alignleft">';
echo '</div></div>';
echo '<div class="col-sm-6">';
if(!empty($akce_url)){
echo '<a href="' . $akce_url . '" class="akce-more" target="new">Web akce ></a>';
} else {
echo '<a href="' . get_permalink() . '" class="akce-more">Víc info ></a>';
}
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
endforeach;
echo '</div>';
?>
<?php else : ?>
<?php get_template_part( 'no-results', 'archive' ); ?>
<?php endif; ?>
</main><!-- #main -->
</section><!-- #primary -->
<?php // get_sidebar(); ?>
</div>
<?php get_footer(); ?>