posts_nav_link( string $sep = '', string $prelabel = '', string $nxtlabel = '' )

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


Description Description


Parameters Parameters

$sep

(string) (Optional) Separator for posts navigation links.

Default value: ''

$prelabel

(string) (Optional) Label for previous pages.

Default value: ''

$nxtlabel

(string) (Optional) Label for next pages.

Default value: ''


Top ↑

Source Source

File: wp-includes/link-template.php

function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) {
	$args = array_filter( compact( 'sep', 'prelabel', 'nxtlabel' ) );
	echo get_posts_nav_link( $args );
}

Top ↑

Changelog Changelog

Changelog
Version Description
0.71 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 4 content
    Contributed by Codex

    Kubrick Theme Format

    The Kubrick theme format for posts navigation, could be formatted this way. However, using posts_nav_link() in this way will result in unintended behavior, such as double stacked next and previous links that link to the incorrect sections.

    The Kubrick Theme actually uses next_posts_link() and previous_posts_link().

    This is poor code and should not be used:

    <div class="navigation">
    <div class="alignleft"><?php posts_nav_link( '', '', '&laquo; Previous Entries' ); ?></div>
    <div class="alignright"><?php posts_nav_link( '', 'Next Entries &raquo;', '' ); ?></div>
    </div>
    

    This is better code:

    <div class="navigation">
    <div class="alignleft"><?php previous_posts_link( '&laquo; Previous Entries' ); ?></div>
    <div class="alignright"><?php next_posts_link( 'Next Entries &raquo;', '' ); ?></div>
    </div>
    
  2. Skip to note 5 content
    Contributed by Codex

    You can change the text in each of the links and in the text in between the links.

    You can go back to the previous page or you can go forward to the next page.

    <p><?php posts_nav_link( ' or ', 'You can go back to the previous page', 'you can go forward to the next page' ); ?>.</p>
    

You must log in before being able to contribute a note or feedback.