-
Notifications
You must be signed in to change notification settings - Fork 0
/
template-blog.php
executable file
·54 lines (45 loc) · 1.64 KB
/
template-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
<?php
/**
* Template Name: Blog
*/
get_header(); ?>
<div id="primary" class="site-content span9">
<?php
$no_results = '';
if( ! have_posts() ) {
$no_results = 'no-results';
}
?>
<div class="content-inner <?php echo $no_results ?>">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query = 'offset=0&paged='.$paged;
$cat_option = dw_get_option('dw_blog_cat');
if( $cat_option && term_exists( (int) $cat_option, 'category' ) ) {
$query .= '&cat='.$cat_option;
} else {
$cat_name = 'Blog';
if( term_exists( $cat_name, 'category' ) ) {
$query .= '&category_name='.$cat_name;
}
}
$number_posts = dw_get_option('dw_blog_number_posts');
if( $number_posts ) {
$query .= '&posts_per_page='.$number_posts;
}
$blogs = new WP_Query($query);
if ( $blogs->have_posts() ) :
?>
<?php while ( $blogs->have_posts() ) : $blogs->the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'no-results', 'archive' ); ?>
<?php endif; ?>
</div>
<?php
dw_focus_pagenavi($blogs, dw_get_option('dw_blog_navigation', 'number') );
?>
</div>
<?php get_sidebar( 'blog' ); ?>
<?php get_footer(); ?>