get_previous_posts_page_link() WordPress Function

The get_previous_posts_page_link() function in WordPress allows you to get the link to the previous posts page. This is useful if you are creating a custom pagination system and need to link to the previous page of posts.

get_previous_posts_page_link() #

Retrieves the previous posts page link.


Description

Will only return string, if not on a single page or post.

Backported to 2.0.10 from 2.1.3.


Top ↑

Return

(string|void) The link for the previous posts page.


Top ↑

Source

File: wp-includes/link-template.php

function get_previous_posts_page_link() {
	global $paged;

	if ( ! is_single() ) {
		$nextpage = (int) $paged - 1;
		if ( $nextpage < 1 ) {
			$nextpage = 1;
		}
		return get_pagenum_link( $nextpage );
	}
}


Top ↑

Changelog

Changelog
VersionDescription
2.0.10Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More