get_previous_comments_link

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

WordPress Version: 6.2

/**
 * Retrieves the link to the previous comments page.
 *
 * @since 2.7.1
 *
 * @param string $label Optional. Label for comments link text. Default empty.
 * @return string|void HTML-formatted link for the previous page of comments.
 */
function get_previous_comments_link($label = '')
{
    if (!is_singular()) {
        return;
    }
    $page = get_query_var('cpage');
    if ((int) $page <= 1) {
        return;
    }
    $previous_page = (int) $page - 1;
    if (empty($label)) {
        $label = __('&laquo; Older Comments');
    }
    /**
     * Filters the anchor tag attributes for the previous comments page link.
     *
     * @since 2.7.0
     *
     * @param string $attributes Attributes for the anchor tag.
     */
    $attr = apply_filters('previous_comments_link_attributes', '');
    return sprintf('<a href="%1$s" %2$s>%3$s</a>', esc_url(get_comments_pagenum_link($previous_page)), $attr, preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label));
}

WordPress Version: 5.6

/**
 * Retrieves the link to the previous comments page.
 *
 * @since 2.7.1
 *
 * @param string $label Optional. Label for comments link text. Default empty.
 * @return string|void HTML-formatted link for the previous page of comments.
 */
function get_previous_comments_link($label = '')
{
    if (!is_singular()) {
        return;
    }
    $page = get_query_var('cpage');
    if ((int) $page <= 1) {
        return;
    }
    $prevpage = (int) $page - 1;
    if (empty($label)) {
        $label = __('&laquo; Older Comments');
    }
    /**
     * Filters the anchor tag attributes for the previous comments page link.
     *
     * @since 2.7.0
     *
     * @param string $attributes Attributes for the anchor tag.
     */
    return '<a href="' . esc_url(get_comments_pagenum_link($prevpage)) . '" ' . apply_filters('previous_comments_link_attributes', '') . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) . '</a>';
}

WordPress Version: 4.6

/**
 * Retrieves the link to the previous comments page.
 *
 * @since 2.7.1
 *
 * @param string $label Optional. Label for comments link text. Default empty.
 * @return string|void HTML-formatted link for the previous page of comments.
 */
function get_previous_comments_link($label = '')
{
    if (!is_singular()) {
        return;
    }
    $page = get_query_var('cpage');
    if (intval($page) <= 1) {
        return;
    }
    $prevpage = intval($page) - 1;
    if (empty($label)) {
        $label = __('&laquo; Older Comments');
    }
    /**
     * Filters the anchor tag attributes for the previous comments page link.
     *
     * @since 2.7.0
     *
     * @param string $attributes Attributes for the anchor tag.
     */
    return '<a href="' . esc_url(get_comments_pagenum_link($prevpage)) . '" ' . apply_filters('previous_comments_link_attributes', '') . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) . '</a>';
}

WordPress Version: 4.4

/**
 * Return the previous comments page link.
 *
 * @since 2.7.1
 *
 * @param string $label Optional. Label for comments link text.
 * @return string|void HTML-formatted link for the previous page of comments.
 */
function get_previous_comments_link($label = '')
{
    if (!is_singular()) {
        return;
    }
    $page = get_query_var('cpage');
    if (intval($page) <= 1) {
        return;
    }
    $prevpage = intval($page) - 1;
    if (empty($label)) {
        $label = __('&laquo; Older Comments');
    }
    /**
     * Filter the anchor tag attributes for the previous comments page link.
     *
     * @since 2.7.0
     *
     * @param string $attributes Attributes for the anchor tag.
     */
    return '<a href="' . esc_url(get_comments_pagenum_link($prevpage)) . '" ' . apply_filters('previous_comments_link_attributes', '') . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) . '</a>';
}

WordPress Version: 4.3

/**
 * Return the previous comments page link.
 *
 * @since 2.7.1
 *
 * @param string $label Optional. Label for comments link text.
 * @return string|void HTML-formatted link for the previous page of comments.
 */
function get_previous_comments_link($label = '')
{
    if (!is_singular() || !get_option('page_comments')) {
        return;
    }
    $page = get_query_var('cpage');
    if (intval($page) <= 1) {
        return;
    }
    $prevpage = intval($page) - 1;
    if (empty($label)) {
        $label = __('&laquo; Older Comments');
    }
    /**
     * Filter the anchor tag attributes for the previous comments page link.
     *
     * @since 2.7.0
     *
     * @param string $attributes Attributes for the anchor tag.
     */
    return '<a href="' . esc_url(get_comments_pagenum_link($prevpage)) . '" ' . apply_filters('previous_comments_link_attributes', '') . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) . '</a>';
}

WordPress Version: 4.1

/**
 * Return the previous comments page link.
 *
 * @since 2.7.1
 *
 * @param string $label Optional. Label for comments link text.
 * @return string|null HTML-formatted link for the previous page of comments.
 */
function get_previous_comments_link($label = '')
{
    if (!is_singular() || !get_option('page_comments')) {
        return;
    }
    $page = get_query_var('cpage');
    if (intval($page) <= 1) {
        return;
    }
    $prevpage = intval($page) - 1;
    if (empty($label)) {
        $label = __('&laquo; Older Comments');
    }
    /**
     * Filter the anchor tag attributes for the previous comments page link.
     *
     * @since 2.7.0
     *
     * @param string $attributes Attributes for the anchor tag.
     */
    return '<a href="' . esc_url(get_comments_pagenum_link($prevpage)) . '" ' . apply_filters('previous_comments_link_attributes', '') . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) . '</a>';
}

WordPress Version: 3.9

/**
 * Return the previous comments page link.
 *
 * @since 2.7.1
 *
 * @param string $label Optional. Label for comments link text.
 * @return string|null
 */
function get_previous_comments_link($label = '')
{
    if (!is_singular() || !get_option('page_comments')) {
        return;
    }
    $page = get_query_var('cpage');
    if (intval($page) <= 1) {
        return;
    }
    $prevpage = intval($page) - 1;
    if (empty($label)) {
        $label = __('&laquo; Older Comments');
    }
    /**
     * Filter the anchor tag attributes for the previous comments page link.
     *
     * @since 2.7.0
     *
     * @param string $attributes Attributes for the anchor tag.
     */
    return '<a href="' . esc_url(get_comments_pagenum_link($prevpage)) . '" ' . apply_filters('previous_comments_link_attributes', '') . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) . '</a>';
}

WordPress Version: 3.7

/**
 * Return the previous comments page link.
 *
 * @since 2.7.1
 *
 * @param string $label Optional. Label for comments link text.
 * @return string|null
 */
function get_previous_comments_link($label = '')
{
    if (!is_singular() || !get_option('page_comments')) {
        return;
    }
    $page = get_query_var('cpage');
    if (intval($page) <= 1) {
        return;
    }
    $prevpage = intval($page) - 1;
    if (empty($label)) {
        $label = __('&laquo; Older Comments');
    }
    return '<a href="' . esc_url(get_comments_pagenum_link($prevpage)) . '" ' . apply_filters('previous_comments_link_attributes', '') . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) . '</a>';
}