the_post_navigation( array $args = array() )

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


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'.



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



User Contributed Notes

  1. Skip to note 4 content

    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.