Title: get_previous_posts_link
Published: April 25, 2014
Last modified: February 24, 2026

---

# get_previous_posts_link( string $label = null ): string|void

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#wp--skip-link--target)

Retrieves the previous posts page link.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#parameters)󠁿

 `$label`stringoptional

Previous page link text.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#return)󠁿

 string|void HTML-formatted previous page link.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#source)󠁿

    ```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 sprintf(
    			'<a href="%1$s" %2$s>%3$s</a>',
    			previous_posts( false ),
    			$attr,
    			preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label )
    		);
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/link-template.php#L2671)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/link-template.php#L2671-L2695)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#hooks)󠁿

 [apply_filters( ‘previous_posts_link_attributes’, string $attributes )](https://developer.wordpress.org/reference/hooks/previous_posts_link_attributes/)

Filters the anchor tag attributes for the previous posts page link.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#related)󠁿

| Uses | Description | 
| [is_single()](https://developer.wordpress.org/reference/functions/is_single/)`wp-includes/query.php` |

Determines whether the query is for an existing single post.

  | 
| [previous_posts()](https://developer.wordpress.org/reference/functions/previous_posts/)`wp-includes/link-template.php` |

Displays or retrieves the previous posts page link.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#)

| Used by | Description | 
| [get_the_posts_navigation()](https://developer.wordpress.org/reference/functions/get_the_posts_navigation/)`wp-includes/link-template.php` |

Returns the navigation to next/previous set of posts, when applicable.

  | 
| [previous_posts_link()](https://developer.wordpress.org/reference/functions/previous_posts_link/)`wp-includes/link-template.php` |

Displays the previous posts page link.

  | 
| [get_posts_nav_link()](https://developer.wordpress.org/reference/functions/get_posts_nav_link/)`wp-includes/link-template.php` |

Retrieves the post pages link navigation for previous and next pages.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#comment-content-739)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/get_previous_posts_link/#comment-739)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_previous_posts_link%2F%23comment-739)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_previous_posts_link%2F%23comment-739)
 4.  **Default Usage**
 5.      ```php
         echo get_previous_posts_link();
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_previous_posts_link%2F%3Freplytocom%3D739%23feedback-editor-739)
 7.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/get_previous_posts_link/?output_format=md#comment-content-3729)
 8.    [Akira Tachibana](https://profiles.wordpress.org/atachibana/)  [  6 years ago  ](https://developer.wordpress.org/reference/functions/get_previous_posts_link/#comment-3729)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_previous_posts_link%2F%23comment-3729)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_previous_posts_link%2F%23comment-3729)
 10. **[From Codex] Removing Trailing Slashes from Prev & Next links**
 11. If you are using no-end-trailing slashes for your URLs. You may add following 
     filter in your functions file to remove trailing slashes from generated links 
     from `get_previous_posts_links()` function.
 12.     ```php
         <?php 
         add_filter( 'get_pagenum_link', 'user_trailingslashit' );
         ?>
         ```
     
 13.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_previous_posts_link%2F%3Freplytocom%3D3729%23feedback-editor-3729)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_previous_posts_link%2F)
before being able to contribute a note or feedback.