Wordpress: Hiding the Comment Link Without Disabling Pings
I saw this question over on Holly Lisle’s weblog, and thought I’d try to help. After a number of posts eaten by the comment gnomes, I think I’ve found the answer.
Since this might be useful to someone else, I’ve decided to post it here.
In your Wordpress template, find where you call comments_popup_link(). It probably looks something like this:
<?php comments_popup_link('No Comments', '1 Comment', '% Comments') ?>
You want to replace that with something that looks like this:
<?php
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];
if1 {
commments_popup_link('No Comments', '1 Comment', '% Comments',
'comments-link','');
}
?>
Note: I’ve only tried this with WP 1.5+.
Popularity: 6%
- $number != 0) || !('closed' == $post->comment_status [↩]
One Comment
Leave a Reply
![[RSS: Posts]](http://jasonpenney.net/wp-includes/images/rss.png)





E. C. Segar’s Popeye Vol. 3: Let’s You and Him Fight!
The Art of Happiness in a Troubled World
Paddington Takes the Test
Odd and the Frost Giants
The Lies of Locke Lamora


so thanks for this php code I was searching codes like this