paginate_comments_links

The timeline below displays how wordpress function paginate_comments_links has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.4

/**
 * Displays or retrieves pagination links for the comments on the current post.
 *
 * @see paginate_links()
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param string|array $args Optional args. See paginate_links(). Default empty array.
 * @return void|string|array Void if 'echo' argument is true and 'type' is not an array,
 *                           or if the query is not for an existing single post of any post type.
 *                           Otherwise, markup for comment page links or array of comment page links,
 *                           depending on 'type' argument.
 */
function paginate_comments_links($args = array())
{
    global $wp_rewrite;
    if (!is_singular()) {
        return;
    }
    $page = get_query_var('cpage');
    if (!$page) {
        $page = 1;
    }
    $max_page = get_comment_pages_count();
    $defaults = array('base' => add_query_arg('cpage', '%#%'), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'type' => 'plain', 'add_fragment' => '#comments');
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
    }
    $args = wp_parse_args($args, $defaults);
    $page_links = paginate_links($args);
    if ($args['echo'] && 'array' !== $args['type']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}

WordPress Version: 5.3

/**
 * Displays or retrieves pagination links for the comments on the current post.
 *
 * @see paginate_links()
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param string|array $args Optional args. See paginate_links(). Default empty array.
 * @return string|array|void Markup for comment page links or array of comment page links.
 */
function paginate_comments_links($args = array())
{
    global $wp_rewrite;
    if (!is_singular()) {
        return;
    }
    $page = get_query_var('cpage');
    if (!$page) {
        $page = 1;
    }
    $max_page = get_comment_pages_count();
    $defaults = array('base' => add_query_arg('cpage', '%#%'), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'type' => 'plain', 'add_fragment' => '#comments');
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
    }
    $args = wp_parse_args($args, $defaults);
    $page_links = paginate_links($args);
    if ($args['echo'] && 'array' !== $args['type']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}

WordPress Version: 5.1

/**
 * Displays or retrieves pagination links for the comments on the current post.
 *
 * @see paginate_links()
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string|array $args Optional args. See paginate_links(). Default empty array.
 * @return string|array|void Markup for comment page links or array of comment page links.
 */
function paginate_comments_links($args = array())
{
    global $wp_rewrite;
    if (!is_singular()) {
        return;
    }
    $page = get_query_var('cpage');
    if (!$page) {
        $page = 1;
    }
    $max_page = get_comment_pages_count();
    $defaults = array('base' => add_query_arg('cpage', '%#%'), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'type' => 'plain', 'add_fragment' => '#comments');
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
    }
    $args = wp_parse_args($args, $defaults);
    $page_links = paginate_links($args);
    if ($args['echo'] && 'array' !== $args['type']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}

WordPress Version: 4.6

/**
 * Displays or retrieves pagination links for the comments on the current post.
 *
 * @see paginate_links()
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string|array $args Optional args. See paginate_links(). Default empty array.
 * @return string|void Markup for pagination links.
 */
function paginate_comments_links($args = array())
{
    global $wp_rewrite;
    if (!is_singular()) {
        return;
    }
    $page = get_query_var('cpage');
    if (!$page) {
        $page = 1;
    }
    $max_page = get_comment_pages_count();
    $defaults = array('base' => add_query_arg('cpage', '%#%'), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'add_fragment' => '#comments');
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
    }
    $args = wp_parse_args($args, $defaults);
    $page_links = paginate_links($args);
    if ($args['echo']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}

WordPress Version: 4.5

/**
 * Create pagination links for the comments on the current post.
 *
 * @see paginate_links()
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string|array $args Optional args. See paginate_links().
 * @return string|void Markup for pagination links.
 */
function paginate_comments_links($args = array())
{
    global $wp_rewrite;
    if (!is_singular()) {
        return;
    }
    $page = get_query_var('cpage');
    if (!$page) {
        $page = 1;
    }
    $max_page = get_comment_pages_count();
    $defaults = array('base' => add_query_arg('cpage', '%#%'), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'add_fragment' => '#comments');
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
    }
    $args = wp_parse_args($args, $defaults);
    $page_links = paginate_links($args);
    if ($args['echo']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}

WordPress Version: 4.4

/**
 * Create pagination links for the comments on the current post.
 *
 * @see paginate_links()
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string|array $args Optional args. See paginate_links().
 * @return string|void Markup for pagination links.
*/
function paginate_comments_links($args = array())
{
    global $wp_rewrite;
    if (!is_singular()) {
        return;
    }
    $page = get_query_var('cpage');
    if (!$page) {
        $page = 1;
    }
    $max_page = get_comment_pages_count();
    $defaults = array('base' => add_query_arg('cpage', '%#%'), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'add_fragment' => '#comments');
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
    }
    $args = wp_parse_args($args, $defaults);
    $page_links = paginate_links($args);
    if ($args['echo']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}

WordPress Version: 4.3

/**
 * Create pagination links for the comments on the current post.
 *
 * @see paginate_links()
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string|array $args Optional args. See paginate_links().
 * @return string|void Markup for pagination links.
*/
function paginate_comments_links($args = array())
{
    global $wp_rewrite;
    if (!is_singular() || !get_option('page_comments')) {
        return;
    }
    $page = get_query_var('cpage');
    if (!$page) {
        $page = 1;
    }
    $max_page = get_comment_pages_count();
    $defaults = array('base' => add_query_arg('cpage', '%#%'), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'add_fragment' => '#comments');
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
    }
    $args = wp_parse_args($args, $defaults);
    $page_links = paginate_links($args);
    if ($args['echo']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}

WordPress Version: 4.2

/**
 * Create pagination links for the comments on the current post.
 *
 * @see paginate_links()
 * @since 2.7.0
 *
 * @param string|array $args Optional args. See paginate_links().
 * @return string Markup for pagination links.
*/
function paginate_comments_links($args = array())
{
    global $wp_rewrite;
    if (!is_singular() || !get_option('page_comments')) {
        return;
    }
    $page = get_query_var('cpage');
    if (!$page) {
        $page = 1;
    }
    $max_page = get_comment_pages_count();
    $defaults = array('base' => add_query_arg('cpage', '%#%'), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'add_fragment' => '#comments');
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
    }
    $args = wp_parse_args($args, $defaults);
    $page_links = paginate_links($args);
    if ($args['echo']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}

WordPress Version: 3.7

/**
 * Create pagination links for the comments on the current post.
 *
 * @see paginate_links()
 * @since 2.7.0
 *
 * @param string|array $args Optional args. See paginate_links().
 * @return string Markup for pagination links.
*/
function paginate_comments_links($args = array())
{
    global $wp_rewrite;
    if (!is_singular() || !get_option('page_comments')) {
        return;
    }
    $page = get_query_var('cpage');
    if (!$page) {
        $page = 1;
    }
    $max_page = get_comment_pages_count();
    $defaults = array('base' => add_query_arg('cpage', '%#%'), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'add_fragment' => '#comments');
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . 'comment-page-%#%', 'commentpaged');
    }
    $args = wp_parse_args($args, $defaults);
    $page_links = paginate_links($args);
    if ($args['echo']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}