I really like the sounds of this. This is exactly what I want to do. Has anyone had problems implementing this? If not, does anybody see anything wrong with it? Or am I a guinea pig?
Matt probably fixed the dollar sign bug on the forums, so now the code shows up as it should. (Thanks Matt!)
Zach: Just go and implement it by following the instructions, it should work fine… If you’re not feeling safe, create a backup of wp-comments.php. Let me know if it worked!
I’m convinced you aren’t a guinea pig by the way.
why not just make it like this!
/1 for comment 1
/2 for comment 2
or am i asking for too much! π
The reason that comment IDs are used instead of comment order is that the links are supposed to be permalinks. If you link to the fifth comment in a thread, and then the third comment gets deleted, your link is broken if you use the above method. It would also be broken if a comment is held for moderation and approved later, as once it’s approved it would show up in the normal flow with the time it was posted. Using the ID provides a permanent anchor for every comment as long as it exists on the page.
Matt: Yeah, but if a comment is deleted in a default WP install, the permalink won’t point to any comment anymore, but just to the post itself…
I get your point; however I’ll still use these comment permalinks just because of the fact that nobody’s linking to comments on my blog but me π
Sushubh:
That won’t work, unless .htaccess allows rewriting # (which it doesn’t as far as I know).
You can’t access fragment identifiers (#anchors) with mod_rewrite. The post plus a number at the end is already used for posts with multiple pages.
If a comment is deleted, I believe it is good form to leave it’s carcass in the flow. Simply put ‘Flame removed.’, etc. But, now that I think about it, I really don’t relish the idea of seeing 10 comments in a row that say ‘Spam Removed’; that would suck.
However, I do find it confusing as hell when a permalink to a comment says “Link to comment-375 on this page’, especially when it’s like the 3rd from the top. It hurts my trust in the permanence of the link.
So now I don’t know what to do. I’ve already had to override the default ordered list’s numbering because I don’t want the ordered number different than the comment URI number.
Dammit, what have I gotten myself into?
If you don’t trust the permenance than create a custom system based on date and poster-name.
that’s what i’m going to do.
Wait. allusion’s idea can’t work. It makes too much sense. It’s too logical.
Anonymous
[digging it all up again]
Having global comment IDs makes sense as permalinks, but the permalinks are no longer cruft-free. Just longer.
Anyway, I replaced my comment_ID():
function comment_ID() {
global $comment;
echo mysql2date('g:i:sa', $comment->comment_date);
echo '-';
$author = apply_filters('comment_author', $comment->comment_author);
if (empty($author)) {
echo 'Anonymous';
} else {
$author = preg_replace("/[^A-Za-z0-9]/", "", $author);
echo $author;
}
}
It will generate links like “/2004/05/21/hello-world/#3:31:00am-MrWordPress”. Everything works fine, so long as no-one wants to use accented or non-English characters.
It should be obvious that I don’t know what I am doing, but maybe someone else can make this workable. π