Index: link-template.php
===================================================================
--- link-template.php	(revision 50398)
+++ link-template.php	(working copy)
@@ -2718,32 +2718,37 @@
  *                                      Default 'Posts navigation'.
  *     @type string $aria_label         ARIA label text for the nav element. Default 'Posts'.
  *     @type string $class              Custom class for the nav element. Default 'posts-navigation'.
+ *     @type int $max_num_pages         Maximum number of pages.
+ *                                      Default to global `$wp_query->max_num_pages`.
  * }
  * @return string Markup for posts links.
  */
 function get_the_posts_navigation( $args = array() ) {
+	global $wp_query;
+
 	$navigation = '';
 
-	// Don't print empty markup if there's only one page.
-	if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
-		// Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
-		if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
-			$args['aria_label'] = $args['screen_reader_text'];
-		}
+	// Make sure the nav element has an aria-label attribute, fallback to the screen reader text.
+	if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
+		$args['aria_label'] = $args['screen_reader_text'];
+	}
 
-		$args = wp_parse_args(
-			$args,
-			array(
-				'prev_text'          => __( 'Older posts' ),
-				'next_text'          => __( 'Newer posts' ),
-				'screen_reader_text' => __( 'Posts navigation' ),
-				'aria_label'         => __( 'Posts' ),
-				'class'              => 'posts-navigation',
-			)
-		);
+	$args = wp_parse_args(
+		$args,
+		array(
+			'prev_text'          => __( 'Older posts' ),
+			'next_text'          => __( 'Newer posts' ),
+			'screen_reader_text' => __( 'Posts navigation' ),
+			'aria_label'         => __( 'Posts' ),
+			'class'              => 'posts-navigation',
+			'max_num_pages'      => $wp_query->max_num_pages,
+		)
+	);
 
+	// Don't print empty markup if there's only one page.
+	if ( $args['max_num_pages'] > 1 ) {
 		$next_link = get_previous_posts_link( $args['next_text'] );
-		$prev_link = get_next_posts_link( $args['prev_text'] );
+		$prev_link = get_next_posts_link( $args['prev_text'], $args['max_num_pages'] );
 
 		if ( $prev_link ) {
 			$navigation .= '<div class="nav-previous">' . $prev_link . '</div>';
@@ -2785,36 +2790,42 @@
  *                                      Default 'Posts navigation'.
  *     @type string $aria_label         ARIA label text for the nav element. Default 'Posts'.
  *     @type string $class              Custom class for the nav element. Default 'pagination'.
+ *     @type int $total                 Total number of pages.
+ *                                      Default to global `$wp_query->max_num_pages`.
  * }
  * @return string Markup for pagination links.
  */
 function get_the_posts_pagination( $args = array() ) {
+	global $wp_query;
+
 	$navigation = '';
 
-	// Don't print empty markup if there's only one page.
-	if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
-		// Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
-		if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
-			$args['aria_label'] = $args['screen_reader_text'];
-		}
+	// Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
+	if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
+		$args['aria_label'] = $args['screen_reader_text'];
+	}
 
-		$args = wp_parse_args(
-			$args,
-			array(
-				'mid_size'           => 1,
-				'prev_text'          => _x( 'Previous', 'previous set of posts' ),
-				'next_text'          => _x( 'Next', 'next set of posts' ),
-				'screen_reader_text' => __( 'Posts navigation' ),
-				'aria_label'         => __( 'Posts' ),
-				'class'              => 'pagination',
-			)
-		);
+	$args = wp_parse_args(
+		$args,
+		array(
+			'mid_size'           => 1,
+			'prev_text'          => _x( 'Previous', 'previous set of posts' ),
+			'next_text'          => _x( 'Next', 'next set of posts' ),
+			'screen_reader_text' => __( 'Posts navigation' ),
+			'aria_label'         => __( 'Posts' ),
+			'class'              => 'pagination',
+			'total'              => $wp_query->max_num_pages,
+		)
+	);
 
-		// Make sure we get a string back. Plain is the next best thing.
-		if ( isset( $args['type'] ) && 'array' === $args['type'] ) {
-			$args['type'] = 'plain';
-		}
+	// Make sure we get a string back. Plain is the next best thing.
+	if ( isset( $args['type'] ) && 'array' === $args['type'] ) {
+		$args['type'] = 'plain';
+	}
 
+	// Don't print empty markup if there's only one page.
+	if ( $args['total'] > 1 ) {
+
 		// Set up paginated links.
 		$links = paginate_links( $args );
 
