-
Notifications
You must be signed in to change notification settings - Fork 0
/
templ-blog.php
executable file
·218 lines (198 loc) · 9.61 KB
/
templ-blog.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
/*
* Template Name: Blog
*/
get_header();
// with sidebar
if ( ot_get_option( 'uni_blog_archive_with_sidebar' ) == 'on' ) {
?>
<section class="uni-container">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1 class="blockTitle"><?php the_title() ?></h1>
<?php endwhile; endif; ?>
<div class="blogCategoryList">
<ul>
<?php wp_list_categories(
array(
'title_li' => '',
'orderby' => 'date',
'order' => 'DESC'
)
);
?>
</ul>
</div>
<div class="wrapper uni-clear">
<div class="contentCenter">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$aBlogArgs = array(
'post_type' => 'post',
'paged' => $paged
);
$oBlogQuery = new wp_query( $aBlogArgs );
if ( $oBlogQuery->have_posts() ) :
while ( $oBlogQuery->have_posts() ) : $oBlogQuery->the_post();
$sAdditionalPostClasses = 'postItemV2 uni-clear uni-no-featured-image';
if ( has_post_thumbnail() ) {
$sAdditionalPostClasses = 'postItemV2 uni-clear';
}
?>
<div id="post-<?php the_ID(); ?>" <?php post_class( $sAdditionalPostClasses ) ?>>
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink() ?>" class="postItemV2Img">
<?php the_post_thumbnail( 'unithumb-coworking-blogpostv2', array( 'alt' => the_title_attribute('echo=0') ) ); ?>
</a>
<?php } ?>
<div class="postItemV2Content">
<div class="postItemMeta">
<time datetime="<?php the_time('Y-m-d'); ?>"><?php the_time( get_option( 'date_format' ) ); ?></time>
<?php
// $aTags = wp_get_post_terms( $post->ID, 'category' );
// if ( $aTags && !is_wp_error( $aTags ) ) :
// $s = count($aTags);
// $i = 1;
// foreach ( $aTags as $oTerm ) {
// echo '<a href="'.esc_url( get_term_link( $oTerm->slug, 'category' ) ).'" class="postItemCategory">'.esc_html( $oTerm->name ).'</a>';
// if ($i < $s) echo ', ';
// $i++;
// }
// endif;
?>
</div>
<h3><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h3>
<?php if ( has_excerpt( $post->ID ) ) { the_excerpt(); } else { uni_coworking_theme_excerpt(32, '', true); } ?>
</div>
</div>
<?php
endwhile;
else :
?>
<?php get_template_part( 'no-results', 'archive' ); ?>
<?php
endif;
?>
<div class="pagination uni-clear">
<?php
$big = 999999999;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'add_args' => '',
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $oBlogQuery->max_num_pages,
'prev_text' => '<i>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Слой_1" x="0px" y="0px" width="7px" height="11px" viewBox="0 0 7 11" enable-background="new 0 0 7 11" xml:space="preserve">
<path fill="#c3c3c3" class="paginationArrowIcon" d="M0.95 4.636L6.049 0L7 0.864L1.899 5.5L7 10.136L6.049 11L0 5.5L0.95 4.636z"/>
</svg>
</i>'.esc_html__('previous', 'coworking'),
'next_text' => esc_html__('next', 'coworking').'<i>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Слой_1" x="0px" y="0px" width="7px" height="11px" viewBox="0 0 7 11" enable-background="new 0 0 7 11" xml:space="preserve">
<path fill="#c3c3c3" class="paginationArrowIcon" d="M6.05 6.364L0.951 11L0 10.136L5.102 5.5L0 0.864L0.951 0L7 5.5L6.05 6.364z"/>
</svg>
</i>',
'type' => 'list',
'end_size' => 3,
'mid_size' => 3
) );
?>
</div>
</div>
<?php //get_sidebar() ?>
</div>
</section>
<?php
// without sidebar
} else {
?>
<section class="uni-container">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1 class="blockTitle"><?php the_title() ?></h1>
<?php endwhile; endif; ?>
<div class="blogCategoryList">
<ul>
<?php wp_list_categories(
array(
'title_li' => '',
'orderby' => 'date',
'order' => 'DESC'
)
);
?>
</ul>
</div>
<div class="blogWrap">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$aBlogArgs = array(
'post_type' => 'post',
'paged' => $paged
);
$oBlogQuery = new wp_query( $aBlogArgs );
if ( $oBlogQuery->have_posts() ) :
while ( $oBlogQuery->have_posts() ) : $oBlogQuery->the_post();
?>
<div id="post-<?php the_ID(); ?>" <?php post_class('postItem') ?>>
<a href="<?php the_permalink() ?>" class="postItemImg">
<?php if ( has_post_thumbnail() ) { ?>
<?php the_post_thumbnail( 'unithumb-coworking-relativepost', array( 'alt' => the_title_attribute('echo=0') ) ); ?>
<?php } else { ?>
<img src="http://placehold.it/370x250/" alt="<?php the_title_attribute() ?>" width="370" height="250">
<?php } ?>
</a>
<div class="postItemMeta">
<time datetime="<?php the_time('Y-m-d'); ?>"><?php the_time( get_option( 'date_format' ) ); ?></time>,
<?php
$aTags = wp_get_post_terms( $post->ID, 'category' );
if ( $aTags && !is_wp_error( $aTags ) ) :
$s = count($aTags);
$i = 1;
foreach ( $aTags as $oTerm ) {
echo '<a href="'.esc_url( get_term_link( $oTerm->slug, 'category' ) ).'" class="postItemCategory">'.esc_html( $oTerm->name ).'</a>';
if ($i < $s) echo ', ';
$i++;
}
endif;
?>
</div>
<h3><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h3>
<?php if ( has_excerpt( $post->ID ) ) { the_excerpt(); } else { uni_coworking_theme_excerpt(32, '', true); } ?>
</div>
<?php
endwhile;
else :
?>
<?php get_template_part( 'no-results', 'archive' ); ?>
<?php
endif;
?>
</div>
<div class="pagination uni-clear">
<?php
$big = 999999999;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'add_args' => '',
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $oBlogQuery->max_num_pages,
'prev_text' => '<i>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Слой_1" x="0px" y="0px" width="7px" height="11px" viewBox="0 0 7 11" enable-background="new 0 0 7 11" xml:space="preserve">
<path fill="#c3c3c3" class="paginationArrowIcon" d="M0.95 4.636L6.049 0L7 0.864L1.899 5.5L7 10.136L6.049 11L0 5.5L0.95 4.636z"/>
</svg>
</i>'.esc_html__('previous', 'coworking'),
'next_text' => esc_html__('next', 'coworking').'<i>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Слой_1" x="0px" y="0px" width="7px" height="11px" viewBox="0 0 7 11" enable-background="new 0 0 7 11" xml:space="preserve">
<path fill="#c3c3c3" class="paginationArrowIcon" d="M6.05 6.364L0.951 11L0 10.136L5.102 5.5L0 0.864L0.951 0L7 5.5L6.05 6.364z"/>
</svg>
</i>',
'type' => 'list',
'end_size' => 3,
'mid_size' => 3
) );
?>
</div>
</section>
<?php
}
get_footer(); ?>