get_comments_pagenum_link

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

WordPress Version: 5.5

/**
 * Retrieves the comments page number link.
 *
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param int $pagenum  Optional. Page number. Default 1.
 * @param int $max_page Optional. The maximum number of comment pages. Default 0.
 * @return string The comments page number link URL.
 */
function get_comments_pagenum_link($pagenum = 1, $max_page = 0)
{
    global $wp_rewrite;
    $pagenum = (int) $pagenum;
    $result = get_permalink();
    if ('newest' === get_option('default_comments_page')) {
        if ($pagenum != $max_page) {
            if ($wp_rewrite->using_permalinks()) {
                $result = user_trailingslashit(trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
            } else {
                $result = add_query_arg('cpage', $pagenum, $result);
            }
        }
    } elseif ($pagenum > 1) {
        if ($wp_rewrite->using_permalinks()) {
            $result = user_trailingslashit(trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
        } else {
            $result = add_query_arg('cpage', $pagenum, $result);
        }
    }
    $result .= '#comments';
    /**
     * Filters the comments page number link for the current request.
     *
     * @since 2.7.0
     *
     * @param string $result The comments page number link.
     */
    return apply_filters('get_comments_pagenum_link', $result);
}

WordPress Version: 5.3

/**
 * Retrieves the comments page number link.
 *
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param int $pagenum  Optional. Page number. Default 1.
 * @param int $max_page Optional. The maximum number of comment pages. Default 0.
 * @return string The comments page number link URL.
 */
function get_comments_pagenum_link($pagenum = 1, $max_page = 0)
{
    global $wp_rewrite;
    $pagenum = (int) $pagenum;
    $result = get_permalink();
    if ('newest' == get_option('default_comments_page')) {
        if ($pagenum != $max_page) {
            if ($wp_rewrite->using_permalinks()) {
                $result = user_trailingslashit(trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
            } else {
                $result = add_query_arg('cpage', $pagenum, $result);
            }
        }
    } elseif ($pagenum > 1) {
        if ($wp_rewrite->using_permalinks()) {
            $result = user_trailingslashit(trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
        } else {
            $result = add_query_arg('cpage', $pagenum, $result);
        }
    }
    $result .= '#comments';
    /**
     * Filters the comments page number link for the current request.
     *
     * @since 2.7.0
     *
     * @param string $result The comments page number link.
     */
    return apply_filters('get_comments_pagenum_link', $result);
}

WordPress Version: 4.6

/**
 * Retrieves the comments page number link.
 *
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param int $pagenum  Optional. Page number. Default 1.
 * @param int $max_page Optional. The maximum number of comment pages. Default 0.
 * @return string The comments page number link URL.
 */
function get_comments_pagenum_link($pagenum = 1, $max_page = 0)
{
    global $wp_rewrite;
    $pagenum = (int) $pagenum;
    $result = get_permalink();
    if ('newest' == get_option('default_comments_page')) {
        if ($pagenum != $max_page) {
            if ($wp_rewrite->using_permalinks()) {
                $result = user_trailingslashit(trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
            } else {
                $result = add_query_arg('cpage', $pagenum, $result);
            }
        }
    } elseif ($pagenum > 1) {
        if ($wp_rewrite->using_permalinks()) {
            $result = user_trailingslashit(trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
        } else {
            $result = add_query_arg('cpage', $pagenum, $result);
        }
    }
    $result .= '#comments';
    /**
     * Filters the comments page number link for the current request.
     *
     * @since 2.7.0
     *
     * @param string $result The comments page number link.
     */
    return apply_filters('get_comments_pagenum_link', $result);
}

WordPress Version: 4.3

/**
 * Retrieve comments page number link.
 *
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param int $pagenum  Optional. Page number.
 * @param int $max_page Optional. The maximum number of comment pages.
 * @return string The comments page number link URL.
 */
function get_comments_pagenum_link($pagenum = 1, $max_page = 0)
{
    global $wp_rewrite;
    $pagenum = (int) $pagenum;
    $result = get_permalink();
    if ('newest' == get_option('default_comments_page')) {
        if ($pagenum != $max_page) {
            if ($wp_rewrite->using_permalinks()) {
                $result = user_trailingslashit(trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
            } else {
                $result = add_query_arg('cpage', $pagenum, $result);
            }
        }
    } elseif ($pagenum > 1) {
        if ($wp_rewrite->using_permalinks()) {
            $result = user_trailingslashit(trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
        } else {
            $result = add_query_arg('cpage', $pagenum, $result);
        }
    }
    $result .= '#comments';
    /**
     * Filter the comments page number link for the current request.
     *
     * @since 2.7.0
     *
     * @param string $result The comments page number link.
     */
    return apply_filters('get_comments_pagenum_link', $result);
}

WordPress Version: 4.2

/**
 * Retrieve comments page number link.
 *
 * @since 2.7.0
 *
 * @param int $pagenum Optional. Page number.
 * @param int $max_page Optional. The maximum number of comment pages.
 * @return string The comments page number link URL.
 */
function get_comments_pagenum_link($pagenum = 1, $max_page = 0)
{
    global $wp_rewrite;
    $pagenum = (int) $pagenum;
    $result = get_permalink();
    if ('newest' == get_option('default_comments_page')) {
        if ($pagenum != $max_page) {
            if ($wp_rewrite->using_permalinks()) {
                $result = user_trailingslashit(trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
            } else {
                $result = add_query_arg('cpage', $pagenum, $result);
            }
        }
    } elseif ($pagenum > 1) {
        if ($wp_rewrite->using_permalinks()) {
            $result = user_trailingslashit(trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged');
        } else {
            $result = add_query_arg('cpage', $pagenum, $result);
        }
    }
    $result .= '#comments';
    /**
     * Filter the comments page number link for the current request.
     *
     * @since 2.7.0
     *
     * @param string $result The comments page number link.
     */
    $result = apply_filters('get_comments_pagenum_link', $result);
    return $result;
}

WordPress Version: 4.1

/**
 * Retrieve comments page number link.
 *
 * @since 2.7.0
 *
 * @param int $pagenum Optional. Page number.
 * @param int $max_page Optional. The maximum number of comment pages.
 * @return string The comments page number link URL.
 */
function get_comments_pagenum_link($pagenum = 1, $max_page = 0)
{
    global $wp_rewrite;
    $pagenum = (int) $pagenum;
    $result = get_permalink();
    if ('newest' == get_option('default_comments_page')) {
        if ($pagenum != $max_page) {
            if ($wp_rewrite->using_permalinks()) {
                $result = user_trailingslashit(trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
            } else {
                $result = add_query_arg('cpage', $pagenum, $result);
            }
        }
    } elseif ($pagenum > 1) {
        if ($wp_rewrite->using_permalinks()) {
            $result = user_trailingslashit(trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
        } else {
            $result = add_query_arg('cpage', $pagenum, $result);
        }
    }
    $result .= '#comments';
    /**
     * Filter the comments page number link for the current request.
     *
     * @since 2.7.0
     *
     * @param string $result The comments page number link.
     */
    $result = apply_filters('get_comments_pagenum_link', $result);
    return $result;
}

WordPress Version: 3.9

/**
 * Retrieve comments page number link.
 *
 * @since 2.7.0
 *
 * @param int $pagenum Optional. Page number.
 * @return string
 */
function get_comments_pagenum_link($pagenum = 1, $max_page = 0)
{
    global $wp_rewrite;
    $pagenum = (int) $pagenum;
    $result = get_permalink();
    if ('newest' == get_option('default_comments_page')) {
        if ($pagenum != $max_page) {
            if ($wp_rewrite->using_permalinks()) {
                $result = user_trailingslashit(trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
            } else {
                $result = add_query_arg('cpage', $pagenum, $result);
            }
        }
    } elseif ($pagenum > 1) {
        if ($wp_rewrite->using_permalinks()) {
            $result = user_trailingslashit(trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
        } else {
            $result = add_query_arg('cpage', $pagenum, $result);
        }
    }
    $result .= '#comments';
    /**
     * Filter the comments page number link for the current request.
     *
     * @since 2.7.0
     *
     * @param string $result The comments page number link.
     */
    $result = apply_filters('get_comments_pagenum_link', $result);
    return $result;
}

WordPress Version: 3.7

/**
 * Retrieve comments page number link.
 *
 * @since 2.7.0
 *
 * @param int $pagenum Optional. Page number.
 * @return string
 */
function get_comments_pagenum_link($pagenum = 1, $max_page = 0)
{
    global $wp_rewrite;
    $pagenum = (int) $pagenum;
    $result = get_permalink();
    if ('newest' == get_option('default_comments_page')) {
        if ($pagenum != $max_page) {
            if ($wp_rewrite->using_permalinks()) {
                $result = user_trailingslashit(trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
            } else {
                $result = add_query_arg('cpage', $pagenum, $result);
            }
        }
    } elseif ($pagenum > 1) {
        if ($wp_rewrite->using_permalinks()) {
            $result = user_trailingslashit(trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
        } else {
            $result = add_query_arg('cpage', $pagenum, $result);
        }
    }
    $result .= '#comments';
    $result = apply_filters('get_comments_pagenum_link', $result);
    return $result;
}