WordPress at a glance

get_previous_posts_link() WP 1.0

Retrieves the previous posts page link.

Works based on: previous_posts()
Hooks from the function
Return

String/null. HTML-formatted previous page link.

Usage

get_previous_posts_link( $label );
$label(string)
Previous page link text.
Default: null

Notes

  • Global. Int. $paged

Changelog

Since 2.7.0 Introduced.

Code of get previous posts link: wp-includes/link-template.php WP 5.2.2

<?php
function get_previous_posts_link( $label = null ) {
	global $paged;

	if ( null === $label ) {
		$label = __( '&laquo; Previous Page' );
	}

	if ( ! is_single() && $paged > 1 ) {
		/**
		 * Filters the anchor tag attributes for the previous posts page link.
		 *
		 * @since 2.7.0
		 *
		 * @param string $attributes Attributes for the anchor tag.
		 */
		$attr = apply_filters( 'previous_posts_link_attributes', '' );
		return '<a href="' . previous_posts( false ) . "\" $attr>" . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label ) . '</a>';
	}
}

Related Functions

From tag: Link (tag A in HTML)

More from category: Archives

No comments
    Hello, !     Log In . Register