A WordPress-centric search engine for devs and theme authors



get_the_comments_navigation ›

Since4.4.0
Deprecatedn/a
get_the_comments_navigation ( $args = array() )
Parameters:
  • (array) $args { Optional. Default comments navigation arguments.
    Required: No
    Default: array()
Returns:
  • (string) Markup for comments links.
Defined at:
Codex:

Retrieves navigation to next/previous set of comments, when applicable.



Source

function get_the_comments_navigation( $args = array() ) {
	$navigation = '';

	// Are there comments to navigate through?
	if ( get_comment_pages_count() > 1 ) {
		$args = wp_parse_args(
			$args,
			array(
				'prev_text'          => __( 'Older comments' ),
				'next_text'          => __( 'Newer comments' ),
				'screen_reader_text' => __( 'Comments navigation' ),
			)
		);

		$prev_link = get_previous_comments_link( $args['prev_text'] );
		$next_link = get_next_comments_link( $args['next_text'] );

		if ( $prev_link ) {
			$navigation .= '<div class="nav-previous">' . $prev_link . '</div>';
		}

		if ( $next_link ) {
			$navigation .= '<div class="nav-next">' . $next_link . '</div>';
		}

		$navigation = _navigation_markup( $navigation, 'comment-navigation', $args['screen_reader_text'] );
	}

	return $navigation;
}