And A WordPress Question
Posted by hollylisle on July 27, 2005 , 16 Comments
Anyone know of a way to keep the “No Comments” link from showing for posts where comments are disabled? If there’s a way to put that in the template, it would save people from clicking through to comment where they can’t.
Tags :
16 Responses to “And A WordPress Question”
said on July 27th, 2005 at 12:47 pm
Have you tried unchecking “Allow comments” and “Allow pings”?
If pings are enabled, they show up as comments. I believe the link is left enabled in case you get any TrackBacks if you just uncheck “Allow comments”.
Jay
said on July 27th, 2005 at 1:15 pm
Unchecking “Allow Pings” blanks the link. That’s a good start. What I want is to have it work sort of the way it worked on Geeklog, of course, where if comments weren’t allowed, no link appeared at all — very clean looking. And with nothing showing if trackbacks are allowed, but none exist. But if pings are allowed, and comments aren’t allowed, and one or more trackbacks exist, that the link will then appear. Kind of a conditional if-then statement. If I knew php, I’d be golden right about now.
said on July 27th, 2005 at 1:24 pm
This will get you a little closer to what you want. In your template find the call to comments_popup_link(). It probably looks like this:
comments_popup_link(’No comments’, ‘1 Comment’, ‘% Comments’);
Change it to this:
comments_popup_link(’No comments’, ‘1 Comment’, ‘% Comments’,'comments-link’,”);
That last empty string argument is what to display when you have no comments.
That still doesn’t get you the trackback support you want.
Jay
said on July 27th, 2005 at 1:26 pm
Of course I meant, “That last empty string argument is what to display when you have comments disabled.”
said on July 27th, 2005 at 1:43 pm
whoops! missed something there (sorry, delete the other comment if you can):
get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");
}
$number = $comment_count_cache[$id];
if (($number != 0) && !(’closed’ == $post->comment_status)) {
comments_popup_link(’No Comments’, ‘1 Comment’, ‘% Comments’,'comments-link’,”);
}
?>
said on July 27th, 2005 at 1:47 pm
Erg!
The code is here:
http://www.jczorkmid.net/~jpenney/comments_popup_link.txt
Sorry for all the bad posts.
said on July 27th, 2005 at 2:29 pm
Love the new site set-up… looks great from here! I’ve been using WP for 6+ months now, and I’ve yet been able to figure out how to get the “next/previous entries” to show up on the bottom of the screen… can you tell me what you tweaked to get that to work? Thanks! Bella
said on July 27th, 2005 at 2:37 pm
Jason — Thank you! That code is awesome. Works perfectly.
said on July 27th, 2005 at 2:38 pm
Though the final link with working code seems to have disappeared. Jason,can you repost?
said on July 27th, 2005 at 2:42 pm
Here’s the code I used for previous/next posts and previous/next-in category posts:
<h4>Previous/Next Posts</h4>
<
p><center><em><?php previous_post(’« %’, ”, ‘yes’);
?>
| <?php next_post(’% » ‘, ”, ‘yes’); ?></em></center></p>
<h4>Previous/Next Posts In Same Category</h4>
<
p><center><em><?php previous_post(’« %’, ”, ‘yes’,
‘in_same_cat’, ‘yes’); ?>
| <?php next_post(’% » ‘, ”, ‘yes’, ‘in_same_cat’, ‘yes’); ?></em></center></p>
These work for WP 1.5.1.3 — not sure how far back they’ll still be valid.
said on July 27th, 2005 at 3:13 pm
Sure, here it is:
http://www.jczorkmid.net/~jpenney/comments_popup_link.txt
said on July 27th, 2005 at 3:23 pm
You know, the comment shows up when I’m logged in, and doesn’t when I’m not.
Is it possible stuck in a moderation queue? I know you don’t like to log into the site, but you might have to to approve the comments with the link (and then you can delete the bad ones).
I probably posted in rapid succession so it thinks I’m a bot.
said on July 27th, 2005 at 4:10 pm
[...] 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. [...]
said on July 27th, 2005 at 4:59 pm
Thanks so much for the code! Gonna go play with it now…
Bella
said on July 28th, 2005 at 1:16 am
Jason — Yes, it was stuck in moderation. I’m not used to moderation yet. I have this thing set to e-mail me about moderation, but it doesn’t seem to be. Yet. I’ll get it worked out. Thank you again for the code. I love it.
said on July 28th, 2005 at 9:33 am
Moderation is a wonderful thing. So far, it’s caught all the spam that’s been tossed to it.
Leave a Reply
You must be logged in to post a comment.