the_comments_navigation()WP 4.4.0

Outputs a navigation block for previous/next comments of a post, if they exist.

When you need to get the result instead of outputting it to the screen, use get_the_comments_navigation()

1 time — 0.00276 sec (very slow) | 50000 times — 5.96595 sec (fast)

No Hooks.

Returns

null. Outputs HTML code.

Usage

<?php the_comments_navigation( $args ); ?>
$args(array)

Parameters of the output block as an array. Can be:

  • prev_text(string)
    Text of the anchor link for previous comments.
    Default: "Previous comments"
  • next_text(string)
    Text of the anchor link for next comments.
    Default: "Next comments"
  • screen_reader_text(string)
    Text for code-reading bots. Used for the navigation block.
    Default "Comments navigation"

Default: array()

Examples

0

#1 Demo

Suppose the post has 44 comments and we are on the second page of the comment pagination, then:

the_comments_navigation();

Outputs HTML code:

<nav class="navigation comment-navigation" role="navigation">

	<h2 class="screen-reader-text">Comments Navigation</h2>

	<div class="nav-links">
		<div class="nav-previous">
			<a href="http://example.com.ru/foo/comment-page-1#comments">Previous comments</a>
		</div>
		<div class="nav-next">
			<a href="http://example.com.ru/foo/comment-page-3#comments">Next comments</a>
		</div>
	</div>

</nav>

Changelog

Since 4.4.0 Introduced.

the_comments_navigation() code WP 6.9

function the_comments_navigation( $args = array() ) {
	echo get_the_comments_navigation( $args );
}