the_post_navigation( array $args = array() )

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


Parameters Parameters

$args

(array) (Optional) See get_the_post_navigation() for available arguments.

Default value: array()


Top ↑

Source Source

File: wp-includes/link-template.php

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


Top ↑

Changelog Changelog

Changelog
Version Description
4.1.0 Introduced.

Top ↑

User Contributed Notes 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;
    endif;
    

Top ↑

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