get_the_comments_navigation()
Retrieves navigation to next/previous set of comments, when applicable.
Uses: get_comment_pages_count(), get_previous_comments_link(), get_next_comments_link(), _navigation_markup()
Used By: the_comments_navigation()
1 time — 0.00276 sec (very slow) | 50000 times — 5.96595 sec (fast)
No Hooks.
Return
String
. Markup for comments links.
Usage
get_the_comments_navigation( $args );
- $args(array)
Optional.
Default: comments navigation arguments
-
prev_text(string)
Anchor text to display in the previous comments link.
Default: 'Older comments' -
next_text(string)
Anchor text to display in the next comments link.
Default: 'Newer comments' -
screen_reader_text(string)
Screen reader text for the nav element.
Default: 'Comments navigation' -
aria_label(string)
ARIA label text for the nav element.
Default: 'Comments' - class(string)
Custom class for the nav element.
Default: 'comment-navigation'
-
Examples
#1 Demo
Suppose the post has 44 comments and we are on the second page of the comment pagination, then:
$html = get_the_comments_navigation();
$html will contain:
<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/foo/comment-page-1#comments">Previous comments</a> </div> <div class="nav-next"> <a href="http://example.com/foo/comment-page-3#comments">Next comments</a> </div> </div> </nav>
Changelog
Since 4.4.0 | Introduced. |
Since 5.3.0 | Added the aria_label parameter. |
Since 5.5.0 | Added the class parameter. |