-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
103 lines (89 loc) · 3.17 KB
/
index.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
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @since 3.0.0
*/
get_header(); ?>
<div id="primary" <?php mb_primary_attr(); ?> role="main">
<?php
$sticky = get_option( 'sticky_posts' );
$featured = new WP_Query( array(
'posts_per_page' => 1,
'post__in' => $sticky,
'ignore_sticky_posts' => 1
) );
global $paged;
if ( ! empty( $sticky[0] ) && is_home() && 2 > $paged ) {
?>
<div id="featured" class="row">
<?php
while ( $featured->have_posts() ) : $featured->the_post();
global $mb_content_area;
$mb_content_area = 'main';
get_template_part( 'content', get_post_format() );
endwhile;
wp_reset_postdata();
?>
</div>
<?php
}
if ( have_posts() ) : ?>
<div class="row">
<?php
while ( have_posts() ) : the_post();
global $wp_query;
$paged = ( get_query_var( 'paged' ) ) ? get_query_var('paged') : 1;
$grid = mb_theme_options( 'grid' );
$posts_per_page = mb_theme_options( 'number' );
$count = $wp_query->current_post;
$total = $wp_query->post_count - 1;
$border = ( 3 == $grid && 1 == $paged ) ? '<div class="c12 border"><span></span></div>' : '';
$two_open_tag = ( ( ( 2 == $grid || 3 == $grid) && 1 == $count && 1 == $paged ) || ( 2 == $grid && 0 == $count && 1 < $paged ) ) ? '<div class="two-col-wrapper">' : '';
$two_close_tag = ( ( 2 == $grid && $total == $count ) || ( 3 == $grid && 2 == $count && 1 == $paged ) ) ? '</div>' : '';
$three_open_tag = ( ( 3 == $grid && 3 == $count && 1 == $paged ) || ( 4 == $grid && 1 == $count && 1 == $paged ) || ( ( 3 == $grid || 4 == $grid ) && 0 == $count && 1 < $paged ) ) ? $border . '<div class="three-col-wrapper">' : '';
$three_close_tag = ( ( 3 == $grid || 4 == $grid ) && $total == $count ) ? '</div>' : '';
if ( 1 < $posts_per_page ) {
echo $two_open_tag;
echo $three_open_tag;
}
global $mb_content_area;
$mb_content_area = 'main';
get_template_part( 'content', get_post_format() );
if ( 1 < $posts_per_page ) {
echo $two_close_tag;
echo $three_close_tag;
}
endwhile;
?>
</div>
<?php
mb_pagination();
else :
?>
<article id="post-0" class="post no-results not-found">
<?php if ( current_user_can( 'edit_posts' ) ) :
// Show a different message to a logged-in user who can add posts.
?>
<h1 class="entry-title"><?php _e( 'No posts to display', 'magazine-basic' ); ?></h1>
<div class="entry-content">
<p><?php printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.', 'magazine-basic' ), admin_url( 'post-new.php' ) ); ?></p>
</div><!-- .entry-content -->
<?php
else :
get_template_part( 'content', 'none' );
endif; // end current_user_can() check
?>
</article><!-- #post-0 -->
<?php
endif;
?>
</div><!-- #primary.c8 -->
<?php get_footer(); ?>