comments_popup_link

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

WordPress Version: 6.3

/**
 * Displays the link to the comments for the current post ID.
 *
 * @since 0.71
 *
 * @param false|string $zero      Optional. String to display when no comments. Default false.
 * @param false|string $one       Optional. String to display when only one comment is available. Default false.
 * @param false|string $more      Optional. String to display when there are more than one comment. Default false.
 * @param string       $css_class Optional. CSS class to use for comments. Default empty.
 * @param false|string $none      Optional. String to display when comments have been turned off. Default false.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    $post_id = get_the_ID();
    $post_title = get_the_title();
    $comments_number = get_comments_number($post_id);
    if (false === $zero) {
        /* translators: %s: Post title. */
        $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $post_title);
    }
    if (false === $one) {
        /* translators: %s: Post title. */
        $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $post_title);
    }
    if (false === $more) {
        /* translators: 1: Number of comments, 2: Post title. */
        $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $comments_number);
        $more = sprintf($more, number_format_i18n($comments_number), $post_title);
    }
    if (false === $none) {
        /* translators: %s: Post title. */
        $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $post_title);
    }
    if (0 == $comments_number && !comments_open() && !pings_open()) {
        printf('<span%1$s>%2$s</span>', (!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '', $none);
        return;
    }
    if (post_password_required()) {
        _e('Enter your password to view comments.');
        return;
    }
    if (0 == $comments_number) {
        $respond_link = get_permalink() . '#respond';
        /**
         * Filters the respond link when a post has no comments.
         *
         * @since 4.4.0
         *
         * @param string $respond_link The default response link.
         * @param int    $post_id      The post ID.
         */
        $comments_link = apply_filters('respond_link', $respond_link, $post_id);
    } else {
        $comments_link = get_comments_link();
    }
    $link_attributes = '';
    /**
     * Filters the comments link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $link_attributes The comments link attributes. Default empty.
     */
    $link_attributes = apply_filters('comments_popup_link_attributes', $link_attributes);
    printf('<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url($comments_link), (!empty($css_class)) ? ' class="' . $css_class . '" ' : '', $link_attributes, get_comments_number_text($zero, $one, $more));
}

WordPress Version: 5.5

/**
 * Displays the link to the comments for the current post ID.
 *
 * @since 0.71
 *
 * @param false|string $zero      Optional. String to display when no comments. Default false.
 * @param false|string $one       Optional. String to display when only one comment is available. Default false.
 * @param false|string $more      Optional. String to display when there are more than one comment. Default false.
 * @param string       $css_class Optional. CSS class to use for comments. Default empty.
 * @param false|string $none      Optional. String to display when comments have been turned off. Default false.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    $post_id = get_the_ID();
    $post_title = get_the_title();
    $number = get_comments_number($post_id);
    if (false === $zero) {
        /* translators: %s: Post title. */
        $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $post_title);
    }
    if (false === $one) {
        /* translators: %s: Post title. */
        $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $post_title);
    }
    if (false === $more) {
        /* translators: 1: Number of comments, 2: Post title. */
        $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number);
        $more = sprintf($more, number_format_i18n($number), $post_title);
    }
    if (false === $none) {
        /* translators: %s: Post title. */
        $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $post_title);
    }
    if (0 == $number && !comments_open() && !pings_open()) {
        echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
        return;
    }
    if (post_password_required()) {
        _e('Enter your password to view comments.');
        return;
    }
    echo '<a href="';
    if (0 == $number) {
        $respond_link = get_permalink() . '#respond';
        /**
         * Filters the respond link when a post has no comments.
         *
         * @since 4.4.0
         *
         * @param string $respond_link The default response link.
         * @param int    $post_id      The post ID.
         */
        echo apply_filters('respond_link', $respond_link, $post_id);
    } else {
        comments_link();
    }
    echo '"';
    if (!empty($css_class)) {
        echo ' class="' . $css_class . '" ';
    }
    $attributes = '';
    /**
     * Filters the comments link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $attributes The comments link attributes. Default empty.
     */
    echo apply_filters('comments_popup_link_attributes', $attributes);
    echo '>';
    comments_number($zero, $one, $more);
    echo '</a>';
}

WordPress Version: 5.3

/**
 * Displays the link to the comments for the current post ID.
 *
 * @since 0.71
 *
 * @param false|string $zero      Optional. String to display when no comments. Default false.
 * @param false|string $one       Optional. String to display when only one comment is available. Default false.
 * @param false|string $more      Optional. String to display when there are more than one comment. Default false.
 * @param string       $css_class Optional. CSS class to use for comments. Default empty.
 * @param false|string $none      Optional. String to display when comments have been turned off. Default false.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    $id = get_the_ID();
    $title = get_the_title();
    $number = get_comments_number($id);
    if (false === $zero) {
        /* translators: %s: Post title. */
        $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $one) {
        /* translators: %s: Post title. */
        $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $more) {
        /* translators: 1: Number of comments, 2: Post title. */
        $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number);
        $more = sprintf($more, number_format_i18n($number), $title);
    }
    if (false === $none) {
        /* translators: %s: Post title. */
        $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (0 == $number && !comments_open() && !pings_open()) {
        echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
        return;
    }
    if (post_password_required()) {
        _e('Enter your password to view comments.');
        return;
    }
    echo '<a href="';
    if (0 == $number) {
        $respond_link = get_permalink() . '#respond';
        /**
         * Filters the respond link when a post has no comments.
         *
         * @since 4.4.0
         *
         * @param string $respond_link The default response link.
         * @param integer $id The post ID.
         */
        echo apply_filters('respond_link', $respond_link, $id);
    } else {
        comments_link();
    }
    echo '"';
    if (!empty($css_class)) {
        echo ' class="' . $css_class . '" ';
    }
    $attributes = '';
    /**
     * Filters the comments link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $attributes The comments link attributes. Default empty.
     */
    echo apply_filters('comments_popup_link_attributes', $attributes);
    echo '>';
    comments_number($zero, $one, $more);
    echo '</a>';
}

WordPress Version: 5.1

/**
 * Displays the link to the comments for the current post ID.
 *
 * @since 0.71
 *
 * @param false|string $zero      Optional. String to display when no comments. Default false.
 * @param false|string $one       Optional. String to display when only one comment is available. Default false.
 * @param false|string $more      Optional. String to display when there are more than one comment. Default false.
 * @param string       $css_class Optional. CSS class to use for comments. Default empty.
 * @param false|string $none      Optional. String to display when comments have been turned off. Default false.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    $id = get_the_ID();
    $title = get_the_title();
    $number = get_comments_number($id);
    if (false === $zero) {
        /* translators: %s: post title */
        $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $one) {
        /* translators: %s: post title */
        $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $more) {
        /* translators: 1: number of comments, 2: post title */
        $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number);
        $more = sprintf($more, number_format_i18n($number), $title);
    }
    if (false === $none) {
        /* translators: %s: post title */
        $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (0 == $number && !comments_open() && !pings_open()) {
        echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
        return;
    }
    if (post_password_required()) {
        _e('Enter your password to view comments.');
        return;
    }
    echo '<a href="';
    if (0 == $number) {
        $respond_link = get_permalink() . '#respond';
        /**
         * Filters the respond link when a post has no comments.
         *
         * @since 4.4.0
         *
         * @param string $respond_link The default response link.
         * @param integer $id The post ID.
         */
        echo apply_filters('respond_link', $respond_link, $id);
    } else {
        comments_link();
    }
    echo '"';
    if (!empty($css_class)) {
        echo ' class="' . $css_class . '" ';
    }
    $attributes = '';
    /**
     * Filters the comments link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $attributes The comments link attributes. Default empty.
     */
    echo apply_filters('comments_popup_link_attributes', $attributes);
    echo '>';
    comments_number($zero, $one, $more);
    echo '</a>';
}

WordPress Version: 4.6

/**
 * Displays the link to the comments for the current post ID.
 *
 * @since 0.71
 *
 * @param string $zero      Optional. String to display when no comments. Default false.
 * @param string $one       Optional. String to display when only one comment is available.
 *                          Default false.
 * @param string $more      Optional. String to display when there are more than one comment.
 *                          Default false.
 * @param string $css_class Optional. CSS class to use for comments. Default empty.
 * @param string $none      Optional. String to display when comments have been turned off.
 *                          Default false.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    $id = get_the_ID();
    $title = get_the_title();
    $number = get_comments_number($id);
    if (false === $zero) {
        /* translators: %s: post title */
        $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $one) {
        /* translators: %s: post title */
        $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $more) {
        /* translators: 1: Number of comments 2: post title */
        $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number);
        $more = sprintf($more, number_format_i18n($number), $title);
    }
    if (false === $none) {
        /* translators: %s: post title */
        $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (0 == $number && !comments_open() && !pings_open()) {
        echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
        return;
    }
    if (post_password_required()) {
        _e('Enter your password to view comments.');
        return;
    }
    echo '<a href="';
    if (0 == $number) {
        $respond_link = get_permalink() . '#respond';
        /**
         * Filters the respond link when a post has no comments.
         *
         * @since 4.4.0
         *
         * @param string $respond_link The default response link.
         * @param integer $id The post ID.
         */
        echo apply_filters('respond_link', $respond_link, $id);
    } else {
        comments_link();
    }
    echo '"';
    if (!empty($css_class)) {
        echo ' class="' . $css_class . '" ';
    }
    $attributes = '';
    /**
     * Filters the comments link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $attributes The comments link attributes. Default empty.
     */
    echo apply_filters('comments_popup_link_attributes', $attributes);
    echo '>';
    comments_number($zero, $one, $more);
    echo '</a>';
}

WordPress Version: 4.5

/**
 * Displays the link to the comments for the current post ID.
 *
 * @since 0.71
 *
 * @param string $zero      Optional. String to display when no comments. Default false.
 * @param string $one       Optional. String to display when only one comment is available.
 *                          Default false.
 * @param string $more      Optional. String to display when there are more than one comment.
 *                          Default false.
 * @param string $css_class Optional. CSS class to use for comments. Default empty.
 * @param string $none      Optional. String to display when comments have been turned off.
 *                          Default false.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    $id = get_the_ID();
    $title = get_the_title();
    $number = get_comments_number($id);
    if (false === $zero) {
        /* translators: %s: post title */
        $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $one) {
        /* translators: %s: post title */
        $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $more) {
        /* translators: 1: Number of comments 2: post title */
        $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number);
        $more = sprintf($more, number_format_i18n($number), $title);
    }
    if (false === $none) {
        /* translators: %s: post title */
        $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (0 == $number && !comments_open() && !pings_open()) {
        echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
        return;
    }
    if (post_password_required()) {
        _e('Enter your password to view comments.');
        return;
    }
    echo '<a href="';
    if (0 == $number) {
        $respond_link = get_permalink() . '#respond';
        /**
         * Filter the respond link when a post has no comments.
         *
         * @since 4.4.0
         *
         * @param string $respond_link The default response link.
         * @param integer $id The post ID.
         */
        echo apply_filters('respond_link', $respond_link, $id);
    } else {
        comments_link();
    }
    echo '"';
    if (!empty($css_class)) {
        echo ' class="' . $css_class . '" ';
    }
    $attributes = '';
    /**
     * Filter the comments link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $attributes The comments link attributes. Default empty.
     */
    echo apply_filters('comments_popup_link_attributes', $attributes);
    echo '>';
    comments_number($zero, $one, $more);
    echo '</a>';
}

WordPress Version: 4.4

/**
 * Displays the link to the comments popup window for the current post ID.
 *
 * Is not meant to be displayed on single posts and pages. Should be used
 * on the lists of posts
 *
 * @global string $wpcommentspopupfile  The URL to use for the popup window.
 * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
 *
 * @since 0.71
 *
 * @param string $zero      Optional. String to display when no comments. Default false.
 * @param string $one       Optional. String to display when only one comment is available.
 *                          Default false.
 * @param string $more      Optional. String to display when there are more than one comment.
 *                          Default false.
 * @param string $css_class Optional. CSS class to use for comments. Default empty.
 * @param string $none      Optional. String to display when comments have been turned off.
 *                          Default false.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    global $wpcommentspopupfile, $wpcommentsjavascript;
    $id = get_the_ID();
    $title = get_the_title();
    $number = get_comments_number($id);
    if (false === $zero) {
        /* translators: %s: post title */
        $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $one) {
        /* translators: %s: post title */
        $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $more) {
        /* translators: 1: Number of comments 2: post title */
        $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number);
        $more = sprintf($more, number_format_i18n($number), $title);
    }
    if (false === $none) {
        /* translators: %s: post title */
        $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (0 == $number && !comments_open() && !pings_open()) {
        echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
        return;
    }
    if (post_password_required()) {
        _e('Enter your password to view comments.');
        return;
    }
    echo '<a href="';
    if ($wpcommentsjavascript) {
        if (empty($wpcommentspopupfile)) {
            $home = home_url();
        } else {
            $home = get_option('siteurl');
        }
        echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
        echo '" onclick="wpopen(this.href); return false"';
    } else {
        // if comments_popup_script() is not in the template, display simple comment link
        if (0 == $number) {
            $respond_link = get_permalink() . '#respond';
            /**
             * Filter the respond link when a post has no comments.
             *
             * @since 4.4.0
             *
             * @param string $respond_link The default response link.
             * @param integer $id The post ID.
             */
            echo apply_filters('respond_link', $respond_link, $id);
        } else {
            comments_link();
        }
        echo '"';
    }
    if (!empty($css_class)) {
        echo ' class="' . $css_class . '" ';
    }
    $attributes = '';
    /**
     * Filter the comments popup link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $attributes The comments popup link attributes. Default empty.
     */
    echo apply_filters('comments_popup_link_attributes', $attributes);
    echo '>';
    comments_number($zero, $one, $more);
    echo '</a>';
}

WordPress Version: 4.3

/**
 * Displays the link to the comments popup window for the current post ID.
 *
 * Is not meant to be displayed on single posts and pages. Should be used
 * on the lists of posts
 *
 * @global string $wpcommentspopupfile  The URL to use for the popup window.
 * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
 *
 * @since 0.71
 *
 * @param string $zero      Optional. String to display when no comments. Default false.
 * @param string $one       Optional. String to display when only one comment is available.
 *                          Default false.
 * @param string $more      Optional. String to display when there are more than one comment.
 *                          Default false.
 * @param string $css_class Optional. CSS class to use for comments. Default empty.
 * @param string $none      Optional. String to display when comments have been turned off.
 *                          Default false.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    global $wpcommentspopupfile, $wpcommentsjavascript;
    $id = get_the_ID();
    $title = get_the_title();
    $number = get_comments_number($id);
    if (false === $zero) {
        /* translators: %s: post title */
        $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $one) {
        /* translators: %s: post title */
        $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $more) {
        /* translators: 1: Number of comments 2: post title */
        $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number);
        $more = sprintf($more, number_format_i18n($number), $title);
    }
    if (false === $none) {
        /* translators: %s: post title */
        $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (0 == $number && !comments_open() && !pings_open()) {
        echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
        return;
    }
    if (post_password_required()) {
        _e('Enter your password to view comments.');
        return;
    }
    echo '<a href="';
    if ($wpcommentsjavascript) {
        if (empty($wpcommentspopupfile)) {
            $home = home_url();
        } else {
            $home = get_option('siteurl');
        }
        echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
        echo '" onclick="wpopen(this.href); return false"';
    } else {
        // if comments_popup_script() is not in the template, display simple comment link
        if (0 == $number) {
            echo get_permalink() . '#respond';
        } else {
            comments_link();
        }
        echo '"';
    }
    if (!empty($css_class)) {
        echo ' class="' . $css_class . '" ';
    }
    $attributes = '';
    /**
     * Filter the comments popup link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $attributes The comments popup link attributes. Default empty.
     */
    echo apply_filters('comments_popup_link_attributes', $attributes);
    echo '>';
    comments_number($zero, $one, $more);
    echo '</a>';
}

WordPress Version: 4.2

/**
 * Displays the link to the comments popup window for the current post ID.
 *
 * Is not meant to be displayed on single posts and pages. Should be used
 * on the lists of posts
 *
 * @global string $wpcommentspopupfile  The URL to use for the popup window.
 * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
 *
 * @since 0.71
 *
 * @param string $zero      Optional. String to display when no comments. Default false.
 * @param string $one       Optional. String to display when only one comment is available.
 *                          Default false.
 * @param string $more      Optional. String to display when there are more than one comment.
 *                          Default false.
 * @param string $css_class Optional. CSS class to use for comments. Default empty.
 * @param string $none      Optional. String to display when comments have been turned off.
 *                          Default false.
 * @return null Returns null on single posts and pages.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    global $wpcommentspopupfile, $wpcommentsjavascript;
    $id = get_the_ID();
    $title = get_the_title();
    $number = get_comments_number($id);
    if (false === $zero) {
        /* translators: %s: post title */
        $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $one) {
        /* translators: %s: post title */
        $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (false === $more) {
        /* translators: 1: Number of comments 2: post title */
        $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number);
        $more = sprintf($more, number_format_i18n($number), $title);
    }
    if (false === $none) {
        /* translators: %s: post title */
        $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title);
    }
    if (0 == $number && !comments_open() && !pings_open()) {
        echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
        return;
    }
    if (post_password_required()) {
        echo __('Enter your password to view comments.');
        return;
    }
    echo '<a href="';
    if ($wpcommentsjavascript) {
        if (empty($wpcommentspopupfile)) {
            $home = home_url();
        } else {
            $home = get_option('siteurl');
        }
        echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
        echo '" onclick="wpopen(this.href); return false"';
    } else {
        // if comments_popup_script() is not in the template, display simple comment link
        if (0 == $number) {
            echo get_permalink() . '#respond';
        } else {
            comments_link();
        }
        echo '"';
    }
    if (!empty($css_class)) {
        echo ' class="' . $css_class . '" ';
    }
    $attributes = '';
    /**
     * Filter the comments popup link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $attributes The comments popup link attributes. Default empty.
     */
    echo apply_filters('comments_popup_link_attributes', $attributes);
    echo '>';
    comments_number($zero, $one, $more);
    echo '</a>';
}

WordPress Version: 3.9

/**
 * Displays the link to the comments popup window for the current post ID.
 *
 * Is not meant to be displayed on single posts and pages. Should be used
 * on the lists of posts
 *
 * @global string $wpcommentspopupfile  The URL to use for the popup window.
 * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
 *
 * @since 0.71
 *
 * @param string $zero      Optional. String to display when no comments. Default false.
 * @param string $one       Optional. String to display when only one comment is available.
 *                          Default false.
 * @param string $more      Optional. String to display when there are more than one comment.
 *                          Default false.
 * @param string $css_class Optional. CSS class to use for comments. Default empty.
 * @param string $none      Optional. String to display when comments have been turned off.
 *                          Default false.
 * @return null Returns null on single posts and pages.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    global $wpcommentspopupfile, $wpcommentsjavascript;
    $id = get_the_ID();
    if (false === $zero) {
        $zero = __('No Comments');
    }
    if (false === $one) {
        $one = __('1 Comment');
    }
    if (false === $more) {
        $more = __('% Comments');
    }
    if (false === $none) {
        $none = __('Comments Off');
    }
    $number = get_comments_number($id);
    if (0 == $number && !comments_open() && !pings_open()) {
        echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
        return;
    }
    if (post_password_required()) {
        echo __('Enter your password to view comments.');
        return;
    }
    echo '<a href="';
    if ($wpcommentsjavascript) {
        if (empty($wpcommentspopupfile)) {
            $home = home_url();
        } else {
            $home = get_option('siteurl');
        }
        echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
        echo '" onclick="wpopen(this.href); return false"';
    } else {
        // if comments_popup_script() is not in the template, display simple comment link
        if (0 == $number) {
            echo get_permalink() . '#respond';
        } else {
            comments_link();
        }
        echo '"';
    }
    if (!empty($css_class)) {
        echo ' class="' . $css_class . '" ';
    }
    $title = the_title_attribute(array('echo' => 0));
    $attributes = '';
    /**
     * Filter the comments popup link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $attributes The comments popup link attributes. Default empty.
     */
    echo apply_filters('comments_popup_link_attributes', $attributes);
    echo ' title="' . esc_attr(sprintf(__('Comment on %s'), $title)) . '">';
    comments_number($zero, $one, $more);
    echo '</a>';
}

WordPress Version: 3.7

/**
 * Displays the link to the comments popup window for the current post ID.
 *
 * Is not meant to be displayed on single posts and pages. Should be used on the
 * lists of posts
 *
 * @global string $wpcommentspopupfile  The URL to use for the popup window.
 * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
 *
 * @since 0.71
 *
 * @param string $zero      Optional. The string to display when no comments. Default false.
 * @param string $one       Optional. The string to display when only one comment is available. Default false.
 * @param string $more      Optional. The string to display when there are more than one comment. Default false.
 * @param string $css_class Optional. The CSS class to use for comments. Default empty.
 * @param string $none      Optional. The string to display when comments have been turned off. Default false.
 * @return null Returns null on single posts and pages.
 */
function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
    global $wpcommentspopupfile, $wpcommentsjavascript;
    $id = get_the_ID();
    if (false === $zero) {
        $zero = __('No Comments');
    }
    if (false === $one) {
        $one = __('1 Comment');
    }
    if (false === $more) {
        $more = __('% Comments');
    }
    if (false === $none) {
        $none = __('Comments Off');
    }
    $number = get_comments_number($id);
    if (0 == $number && !comments_open() && !pings_open()) {
        echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
        return;
    }
    if (post_password_required()) {
        echo __('Enter your password to view comments.');
        return;
    }
    echo '<a href="';
    if ($wpcommentsjavascript) {
        if (empty($wpcommentspopupfile)) {
            $home = home_url();
        } else {
            $home = get_option('siteurl');
        }
        echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
        echo '" onclick="wpopen(this.href); return false"';
    } else {
        // if comments_popup_script() is not in the template, display simple comment link
        if (0 == $number) {
            echo get_permalink() . '#respond';
        } else {
            comments_link();
        }
        echo '"';
    }
    if (!empty($css_class)) {
        echo ' class="' . $css_class . '" ';
    }
    $title = the_title_attribute(array('echo' => 0));
    $attributes = '';
    /**
     * Filter the comments popup link attributes for display.
     *
     * @since 2.5.0
     *
     * @param string $attributes The comments popup link attributes. Default empty.
     */
    echo apply_filters('comments_popup_link_attributes', $attributes);
    echo ' title="' . esc_attr(sprintf(__('Comment on %s'), $title)) . '">';
    comments_number($zero, $one, $more);
    echo '</a>';
}