Skip to content

Commit e970f03

Browse files
committedJul 13, 2015
#6 Posts navigation.
1 parent 5bc31a6 commit e970f03

9 files changed

+74
-103
lines changed
 

‎archive.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
<?php endwhile; ?>
3131
</div>
3232

33-
<?php gather_paging_nav(); ?>
33+
<?php the_posts_navigation( array(
34+
'prev_text' => __( '<span class="meta-nav">&larr;</span> Older posts', 'gather' ),
35+
'next_text' => __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'gather' )
36+
) ); ?>
3437

3538
<?php else : ?>
3639

@@ -43,4 +46,4 @@
4346
</div><!-- #primary -->
4447

4548
<?php get_sidebar(); ?>
46-
<?php get_footer(); ?>
49+
<?php get_footer(); ?>

‎inc/template-tags.php

-56
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,9 @@
22
/**
33
* Custom template tags for this theme.
44
*
5-
* Eventually, some of the functionality here could be replaced by core features.
6-
*
75
* @package Gather
86
*/
97

10-
if ( ! function_exists( 'gather_paging_nav' ) ) :
11-
/**
12-
* Display navigation to next/previous set of posts when applicable.
13-
*/
14-
function gather_paging_nav() {
15-
// Don't print empty markup if there's only one page.
16-
if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
17-
return;
18-
}
19-
?>
20-
<nav class="navigation paging-navigation" role="navigation">
21-
<h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'gather' ); ?></h1>
22-
<div class="nav-links module">
23-
24-
<?php if ( get_next_posts_link() ) : ?>
25-
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'gather' ) ); ?></div>
26-
<?php endif; ?>
27-
28-
<?php if ( get_previous_posts_link() ) : ?>
29-
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'gather' ) ); ?></div>
30-
<?php endif; ?>
31-
32-
</div><!-- .nav-links -->
33-
</nav><!-- .navigation -->
34-
<?php
35-
}
36-
endif;
37-
38-
if ( ! function_exists( 'gather_post_nav' ) ) :
39-
/**
40-
* Display navigation to next/previous post when applicable.
41-
*/
42-
function gather_post_nav() {
43-
// Don't print empty markup if there's nowhere to navigate.
44-
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
45-
$next = get_adjacent_post( false, '', false );
46-
47-
if ( ! $next && ! $previous ) {
48-
return;
49-
}
50-
?>
51-
<nav class="navigation post-navigation" role="navigation">
52-
<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'gather' ); ?></h1>
53-
<div class="nav-links">
54-
<?php
55-
previous_post_link( '<div class="nav-previous">%link</div>', _x( '<span class="meta-nav">&larr;</span> %title', 'Previous post link', 'gather' ) );
56-
next_post_link( '<div class="nav-next">%link</div>', _x( '%title <span class="meta-nav">&rarr;</span>', 'Next post link', 'gather' ) );
57-
?>
58-
</div><!-- .nav-links -->
59-
</nav><!-- .navigation -->
60-
<?php
61-
}
62-
endif;
63-
648
if ( ! function_exists( 'gather_posted_on' ) ) :
659
/**
6610
* Prints HTML with meta information for the current post-date/time and author.

‎index.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
<?php endwhile; ?>
2828
</div>
2929

30-
<?php gather_paging_nav(); ?>
30+
<?php the_posts_navigation( array(
31+
'prev_text' => __( '<span class="meta-nav">&larr;</span> Older posts', 'gather' ),
32+
'next_text' => __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'gather' )
33+
) ); ?>
3134

3235
<?php else : ?>
3336

‎languages/gather.pot

+22-30
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ msgstr ""
3232
msgid "The page you are looking for doesn't exist. Try a search?"
3333
msgstr ""
3434

35+
#: archive.php:34 index.php:31 search.php:29
36+
msgid "<span class=\"meta-nav\">&larr;</span> Older posts"
37+
msgstr ""
38+
39+
#: archive.php:35 index.php:32 search.php:30
40+
msgid "Newer posts <span class=\"meta-nav\">&rarr;</span>"
41+
msgstr ""
42+
3543
#: comments.php:38 comments.php:59
3644
msgid "Comment navigation"
3745
msgstr ""
@@ -81,7 +89,7 @@ msgid ""
8189
"searching can help."
8290
msgstr ""
8391

84-
#: content-page.php:24 inc/template-tags.php:121
92+
#: content-page.php:24 inc/template-tags.php:65
8593
msgid "Edit"
8694
msgstr ""
8795

@@ -193,23 +201,7 @@ msgstr ""
193201
msgid "Search"
194202
msgstr ""
195203

196-
#: inc/template-tags.php:21
197-
msgid "Posts navigation"
198-
msgstr ""
199-
200-
#: inc/template-tags.php:25
201-
msgid "<span class=\"meta-nav\">&larr;</span> Older posts"
202-
msgstr ""
203-
204-
#: inc/template-tags.php:29
205-
msgid "Newer posts <span class=\"meta-nav\">&rarr;</span>"
206-
msgstr ""
207-
208-
#: inc/template-tags.php:52
209-
msgid "Post navigation"
210-
msgstr ""
211-
212-
#: inc/template-tags.php:104 inc/template-tags.php:113
204+
#: inc/template-tags.php:48 inc/template-tags.php:57
213205
#. translators: used between list items, there is a space after the comma
214206
msgid ", "
215207
msgstr ""
@@ -280,22 +272,22 @@ msgctxt "Merriweather font: active or inactive"
280272
msgid "active"
281273
msgstr ""
282274

283-
#: inc/template-tags.php:55
284-
msgctxt "Previous post link"
285-
msgid "<span class=\"meta-nav\">&larr;</span> %title"
286-
msgstr ""
287-
288-
#: inc/template-tags.php:56
289-
msgctxt "Next post link"
290-
msgid "%title <span class=\"meta-nav\">&rarr;</span>"
291-
msgstr ""
292-
293-
#: inc/template-tags.php:80
275+
#: inc/template-tags.php:24
294276
msgctxt "post date"
295277
msgid "%s"
296278
msgstr ""
297279

298-
#: inc/template-tags.php:85
280+
#: inc/template-tags.php:29
299281
msgctxt "post author"
300282
msgid "By %s"
283+
msgstr ""
284+
285+
#: single.php:26
286+
msgctxt "Previous post link"
287+
msgid "<span class=\"meta-nav\">&larr;</span> %title"
288+
msgstr ""
289+
290+
#: single.php:27
291+
msgctxt "Next post link"
292+
msgid "%title <span class=\"meta-nav\">&rarr;</span>"
301293
msgstr ""

‎scss/style.scss

+11-4
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,15 @@ a:active {
590590
/* Paging Navigation
591591
--------------------------------------------------------------*/
592592

593+
.posts-navigation {
594+
background: #fff;
595+
border-radius: 4px;
596+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
597+
margin-bottom:30px;
598+
overflow: hidden;
599+
}
593600
.site-main .comment-navigation,
594-
.site-main .paging-navigation,
601+
.site-main .posts-navigation,
595602
.site-main .post-navigation {
596603
clear:both;
597604
overflow: hidden;
@@ -605,19 +612,19 @@ a:active {
605612
padding: 4% 6% 0;
606613
}
607614
.comment-navigation .nav-previous,
608-
.paging-navigation .nav-previous,
615+
.posts-navigation .nav-previous,
609616
.post-navigation .nav-previous {
610617
float: left;
611618
width: 50%;
612619
}
613620
.comment-navigation .nav-next,
614-
.paging-navigation .nav-next,
621+
.posts-navigation .nav-next,
615622
.post-navigation .nav-next {
616623
float: right;
617624
text-align: right;
618625
width: 50%;
619626
}
620-
.paging-navigation a {
627+
.posts-navigation a {
621628
padding:15px 30px;
622629
display: inline-block;
623630
}

‎search.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
<?php endwhile; ?>
2626
</div>
2727

28-
<?php gather_paging_nav(); ?>
28+
<?php the_posts_navigation( array(
29+
'prev_text' => __( '<span class="meta-nav">&larr;</span> Older posts', 'gather' ),
30+
'next_text' => __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'gather' )
31+
) ); ?>
2932

3033
<?php else : ?>
3134

‎single.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
endif;
2323
?>
2424

25-
<?php gather_post_nav(); ?>
25+
<?php the_post_navigation( array(
26+
'prev_text' => _x( '<span class="meta-nav">&larr;</span> %title', 'Previous post link', 'gather' ),
27+
'next_text' => _x( '%title <span class="meta-nav">&rarr;</span>', 'Next post link', 'gather' )
28+
) ); ?>
2629

2730
<?php endwhile; // end of the loop. ?>
2831
</div>

‎style-rtl.css

+12-4
Original file line numberDiff line numberDiff line change
@@ -1338,8 +1338,16 @@ a:active {
13381338
}
13391339
/* Paging Navigation
13401340
--------------------------------------------------------------*/
1341+
.posts-navigation {
1342+
background: #fff;
1343+
border-radius: 4px;
1344+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
1345+
margin-bottom: 30px;
1346+
overflow: hidden;
1347+
}
1348+
13411349
.site-main .comment-navigation,
1342-
.site-main .paging-navigation,
1350+
.site-main .posts-navigation,
13431351
.site-main .post-navigation {
13441352
clear: both;
13451353
overflow: hidden;
@@ -1356,21 +1364,21 @@ a:active {
13561364
}
13571365

13581366
.comment-navigation .nav-previous,
1359-
.paging-navigation .nav-previous,
1367+
.posts-navigation .nav-previous,
13601368
.post-navigation .nav-previous {
13611369
float: right;
13621370
width: 50%;
13631371
}
13641372

13651373
.comment-navigation .nav-next,
1366-
.paging-navigation .nav-next,
1374+
.posts-navigation .nav-next,
13671375
.post-navigation .nav-next {
13681376
float: left;
13691377
text-align: left;
13701378
width: 50%;
13711379
}
13721380

1373-
.paging-navigation a {
1381+
.posts-navigation a {
13741382
padding: 15px 30px;
13751383
display: inline-block;
13761384
}

‎style.css

+12-4
Original file line numberDiff line numberDiff line change
@@ -1338,8 +1338,16 @@ a:active {
13381338
}
13391339
/* Paging Navigation
13401340
--------------------------------------------------------------*/
1341+
.posts-navigation {
1342+
background: #fff;
1343+
border-radius: 4px;
1344+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
1345+
margin-bottom: 30px;
1346+
overflow: hidden;
1347+
}
1348+
13411349
.site-main .comment-navigation,
1342-
.site-main .paging-navigation,
1350+
.site-main .posts-navigation,
13431351
.site-main .post-navigation {
13441352
clear: both;
13451353
overflow: hidden;
@@ -1356,21 +1364,21 @@ a:active {
13561364
}
13571365

13581366
.comment-navigation .nav-previous,
1359-
.paging-navigation .nav-previous,
1367+
.posts-navigation .nav-previous,
13601368
.post-navigation .nav-previous {
13611369
float: left;
13621370
width: 50%;
13631371
}
13641372

13651373
.comment-navigation .nav-next,
1366-
.paging-navigation .nav-next,
1374+
.posts-navigation .nav-next,
13671375
.post-navigation .nav-next {
13681376
float: right;
13691377
text-align: right;
13701378
width: 50%;
13711379
}
13721380

1373-
.paging-navigation a {
1381+
.posts-navigation a {
13741382
padding: 15px 30px;
13751383
display: inline-block;
13761384
}

0 commit comments

Comments
 (0)
Please sign in to comment.