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+.
- $number != 0) || !('closed' == $post->comment_status [↩]
One Response to “Wordpress: Hiding the Comment Link Without Disabling Pings”
Leave a Reply
Additional comments powered by BackType
![[RSS: Posts]](http://jasonpenney.net/wp-includes/images/rss.png)




The Dead Zone
On Writing
The Complete Peanuts 1950-1952 (Vol. 1)
Contagious
Paddington Goes to Town (Paddington Bear Adventures)


July 26th, 2008 at 3:06 am
so thanks for this php code I was searching codes like this