the_post_navigation( array $args = array() )

Displays the navigation to next/previous post, when applicable.


$args array Optional
See get_the_post_navigation() for available arguments.
More Arguments from get_the_post_navigation( ... $args ) Default post navigation arguments.
  • prev_text string
    Anchor text to display in the previous post link.
    Default '%title'.
  • next_text string
    Anchor text to display in the next post link.
    Default '%title'.
  • in_same_term bool
    Whether link should be in the same taxonomy term.
    Default false.
  • excluded_terms int[]|string
    Array or comma-separated list of excluded term IDs.
  • taxonomy string
    Taxonomy, if $in_same_term is true. Default 'category'.
  • screen_reader_text string
    Screen reader text for the nav element.
    Default 'Post navigation'.
  • aria_label string
    ARIA label text for the nav element. Default 'Posts'.
  • class string
    Custom class for the nav element. Default 'post-navigation'.

Default: array()

Top ↑


File: wp-includes/link-template.php. View all references

function the_post_navigation( $args = array() ) {
	echo get_the_post_navigation( $args );

Top ↑


Version Description
4.1.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by aesbovis

    Customize your posts navigation to get posts in the same tag.

    the_post_navigation( array(
    			'prev_text'					 => __( 'prev chapter: %title' ),
    			'next_text'					 => __( 'next chapter: %title' ),
    			'in_same_term'				 => true,
    			'taxonomy'					 => __( 'post_tag' ),
    			'screen_reader_text' => __( 'Continue Reading' ),
    		) );
  2. Skip to note 2 content
    Contributed by talymo36

    In order to include a header before the navigation and show it only when the navigation links exist:

    $args = array(
        'prev_text' => sprintf( esc_html__( '%s Older', 'wpdocs_blankslate' ), '<span class="meta-nav"> < </span>' ),
        'next_text' => sprintf( esc_html__( 'Newer %s', 'wpdocs_blankslate' ), '<span class="meta-nav"> > </span>' )
    $navigation = get_the_post_navigation( $args );
    if ( $navigation ) :
        echo '<h4>View More</h4>';
        echo $navigation;

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