Okay, I’ve managed to track this down myself. I found where comments_popup_link () is located: it’s (appropriately) in comment-functions.php. In my mind the script has a few bugs and I have changed it as described below:
function comments_popup_link($zero='0 Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
Here the function has defined some defaults, just in case your template left them out.
global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb;
global $comment_count_cache;
if (! is_single() && ! is_page()) {
if ( !isset($comment_count_cache[$id]) )
$comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");
$number = $comment_count_cache[$id];
if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {
echo $none;
return;
Here WP checks to see if 1) there are no comments at this time, 2) “Allow Comments” is not checked, and 3) “Allow Pings” is not checked. If all three are true, WP echoes “Comments Off” — without a link — and returns. The problem here is that echo $none; was not in the original code, so with comments off nothing would appear. I think it’s a good idea to let users know what the comment status is if they’re used to seeing comment links.
} else {
if (!empty($post->post_password)) { // if there's a password
if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
echo('Enter your password to view comments');
return;
}
}
echo '<a href="';
if ($wpcommentsjavascript) {
if ( empty($wpcommentspopupfile) )
$home = get_settings('home');
else
$home = get_settings('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($CSSclass)) {
echo ' class="'.$CSSclass.'"';
}
echo ' title="' . sprintf( __('Comment on %s'), $post->post_title ) .'">';
comments_number($zero, $one, $more, $none, $number);
Here’s where WP jumps to another function in comment-functions.php to insert the number of comments. I changed this line to add the $none parameter.
echo '</a>';
}
}
}
It was also necessary to fix comments_number ():
function comments_number( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $none = 'Comments Off', $number = '' ) {
I changed this line so the function would accept the $none parameter.
global $id, $comment;
$number = get_comments_number( $id );
if ($number == 0) {
if ( comments_open() ) {
$blah = $zero;
} else {
$blah = $none;
}
Here I added the else branch. Because it was missing, if the number of comments was zero the link would always read “0 Comments.” With this fix, if you have zero comments and commenting is off, you’ll see “Comments Off” (or whatever your template passes to comments_popup_link () ). If commenting is on and you have zero comments, you’ll still see “0 Comments.”
} elseif ($number == 1) {
$blah = $one;
} elseif ($number > 1) {
$blah = str_replace('%', $number, $more);
}
echo apply_filters('comments_number', $blah);
}
Of course, if you allow comments to begin with, add a few comments, and then disable comments, your comment links will still show the number of comments added before commenting was disabled.
This should make your comment links display more accurately.