Skip to content

Instantly share code, notes, and snippets.

@bezierer
Created January 5, 2017 15:51
Show Gist options
  • Save bezierer/0f2f9acf735d0c36833ec3a152d8c253 to your computer and use it in GitHub Desktop.
Save bezierer/0f2f9acf735d0c36833ec3a152d8c253 to your computer and use it in GitHub Desktop.
/**
* Modified version of the_post_navigation, does the same, but uses different classes and adds arrows.
*
* @param array $args Arguments array. Lets you set the text for the buttons.
* @return string
*/
function wds_comeback_get_the_posts_navigation( $args = array() ) {
global $wp_query;
// Bail if there's only one page.
if ( 1 === $wp_query->max_num_pages ) {
return '';
}
// Set defaults.
$defaults = array(
'prev_text' => wds_comeback_get_svg( array( 'icon' => 'arrow' ) ) . __( 'Older posts', 'comeback' ),
'next_text' => __( 'Newer posts', 'comeback' ) . wds_comeback_get_svg( array( 'icon' => 'arrow' ) ),
'screen_reader_text' => __( 'Posts navigation', 'comeback' ),
);
$args = wp_parse_args( $args, $defaults );
$navigation = '';
$next_link = get_previous_posts_link( $args['next_text'] );
$prev_link = get_next_posts_link( $args['prev_text'] );
if ( $prev_link ) {
$navigation .= $prev_link;
}
if ( $next_link ) {
$navigation .= $next_link;
}
$navigation = _navigation_markup( $navigation, 'posts-navigation', $args['screen_reader_text'] );
return $navigation;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment