forked from caslay/tiny_theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homepage.php
63 lines (49 loc) · 1.69 KB
/
homepage.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
<?php
//Template Name: Home
get_header()
?>
<div class="container">
<header>
<h1><?php echo get_option('tiny_head_title') ?></h1>
<p><?php echo get_option('tiny_head_description') ?></p>
</header>
<?php $paged = get_query_var('page'); ?>
<?php $home = new WP_Query(array('post_type'=> 'post', 'posts_per_page' =>6, 'paged' => $paged)); ?>
<?php if($home->have_posts()): ?>
<div class="posts">
<?php while($home->have_posts()) : $home->the_post(); ?>
<?php if ( is_sticky() ): ?>
<article id='<?php the_ID(); ?>' <?php post_class('sticky'); ?> >
<?php else: ?>
<article id='<?php the_ID(); ?>' <?php post_class(); ?> >
<?php endif ?>
<h2><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2>
<?php the_excerpt() ?>
</article>
<?php endwhile; ?>
</div>
<div class="pagination">
<?php
global $home;
$total = $home->max_num_pages;
// only bother with the rest if we have more than 1 page!
if ( $total > 1 ) {
// get the current page
if ( !$current_page = get_query_var('page') )
$current_page = 1;
// structure of "format" depends on whether we're using pretty permalinks
$format = get_option('permalink_structure')?'page/%#%/':'&page=%#%';
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => $format,
'current' => $current_page,
'total' => $total,
'mid_size' => 4,
'type' => 'plain'
));
}
?>
</div>
<?php endif; ?>
</div>
<?php get_footer()?>