paginate_comments_links example

// Bail out early if the post ID is not set for some reason.     if ( empty( $block->context['postId'] ) ) {
        return '';
    }

    $comment_vars = build_comment_query_vars_from_block( $block );

    $total   = ( new WP_Comment_Query( $comment_vars ) )->max_num_pages;
    $current = ! empty( $comment_vars['paged'] ) ? $comment_vars['paged'] : null;

    // Render links.     $content = paginate_comments_links(
        array(
            'total'     => $total,
            'current'   => $current,
            'prev_next' => false,
            'echo'      => false,
        )
    );

    if ( empty( $content ) ) {
        return '';
    }

    
'aria_label'         => __( 'Comments' ),
            'class'              => 'comments-pagination',
        )
    );
    $args['echo'] = false;

    // Make sure we get a string back. Plain is the next best thing.     if ( isset( $args['type'] ) && 'array' === $args['type'] ) {
        $args['type'] = 'plain';
    }

    $links = paginate_comments_links( $args );

    if ( $links ) {
        $navigation = _navigation_markup( $links$args['class']$args['screen_reader_text']$args['aria_label'] );
    }

    return $navigation;
}

/** * Displays a paginated navigation to next/previous set of comments, when applicable. * * @since 4.4.0 * * @param array $args See get_the_comments_pagination() for available arguments. Default empty array. */
Home | Imprint | This part of the site doesn't use cookies.