Skip to content

Instantly share code, notes, and snippets.

@Kenshino
Created January 10, 2014 19:07
Show Gist options
  • Save Kenshino/8360507 to your computer and use it in GitHub Desktop.
Save Kenshino/8360507 to your computer and use it in GitHub Desktop.
function wingz_get_next_posts_link( $label = null, $max_page = 0, $query_args = null ) {
global $paged, $wp_query;
if ( !$max_page )
$max_page = $wp_query->max_num_pages;
if ( !$paged )
$paged = 1;
$nextpage = intval($paged) + 1;
if ( null === $label )
$label = __( 'Next Page »' );
if ( null === $query_args){
$query_args = '';
}
if ( !is_single() && ( $nextpage <= $max_page ) ) {
$attr = apply_filters( 'next_posts_link_attributes', '' );
return '<a href="' . next_posts( $max_page, false ) . $query_args . "\" $attr>" . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) . '</a>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment