the_posts_navigation()
Displays the navigation to next/previous set of posts, when applicable.
No Hooks.
Return
null
. Nothing (null).
Usage
the_posts_navigation( $args );
- $args(array)
- See get_the_posts_navigation() for available arguments.
Default: empty array
Examples
#1 Display links to the previous/next set of posts
the_posts_navigation( array( 'prev_text' => 'Previous posts', 'next_text' => 'Next posts', 'screen_reader_text' => 'Navigation', ) );
As a result the following navigation code will be displayed:
<nav class="navigation posts-navigation" role="navigation"> <h2 class="screen-reader-text">Navigation</h2> <div class="nav-links"> <div class="nav-previous"> <a href="http://example.com/page/3/">Previous posts</a> </div> <div class="nav-next"> <a href="http://example.com/">The following posts</a> </div> </div> </nav>
Changelog
Since 4.1.0 | Introduced. |
the_posts_navigation() the posts navigation code WP 6.8
function the_posts_navigation( $args = array() ) { echo get_the_posts_navigation( $args ); }