Nicer comment permalinks
-
Because I didn’t really like those permalinks to comments on my WordPress blog, I made some changes to wp-comments.php.
Instead of https://www.yoursite.com/2004/01/01/a-post/#comment-176, the comments now start counting at 1, so the first comment on that page would be https://www.yoursite.com/2004/01/01/a-post/#comment-1.
Here are the instructions. I’d like to see this implemented in WordPress.
wp-comments.php
search for
<?php foreach ($comments as $comment) { ?>
<li id="comment-<?php comment_ID() ?>">
<?php comment_text() ?>
<cite><?php comment_type(); ?> by <?php comment_author_link() ?> — <?php comment_date() ?> @ "><?php comment_time() ?></cite> <?php edit_comment_link('Edit This', ' |'); ?><?php } // end for each comment ?>
replace with
<?php
$i = 1;
foreach ($comments as $comment) { ?>
<li id="comment-<?php echo $i; ?>">
<?php comment_text() ?>
<cite><?php comment_type(); ?> by <?php comment_author_link() ?> — <?php comment_date() ?> @ #comment-<?php echo $i; ?>"><?php comment_time() ?></cite> <?php edit_comment_link('Edit This', ' |'); ?><?php $i++; } // end for each comment ?>
Edit: The code didn’t show up perfectly. Replace those$
s with a dollar sign.
MaThIbUs
- The topic ‘Nicer comment permalinks’ is closed to new replies.