solostream

Giving each comment its own link in WordPress

| November 28, 2007 | 4 Comments

Being able to link to specific comments in your WordPress blog could be very handy. Good comments can really add a lot of value to a blog, and you or others may want to refer to specific comments in your posts by linking to them. In general, comments can be linked to, but to figure out what the URL is for every comment is virtually impossible, unless…you set up your comments section of your blog so that every comment gets a link.

Here’s how you would create a link around the date and time of your comment:

<p><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a></p>

This piece of code should appear in your comments.php theme file where your comment code appears.

If you want an “Edit Comment” link to appear next to the comment for those who are logged in and have permissions to edit, you would add the following code:

<p><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a><?php edit_comment_link('Edit comment',' ~ ',''); ?></p>

So there you have it boys and girls: now you can link to comments, and share the love with your commenters!

Tags:

Category: Code Snippets

Elegant WP Themes

Comments (4)

Trackback URL | Comments RSS Feed

  1. [...] Garage explains how to give each comment a link in your WordPress theme.  This might be something people would want to do for certain types of blogs where comments are [...]

  2. [...] sayisini uygun bir text formatinda goruntueyebilmesine yardimci olmaktadir. • WordPress Garaji, WordPress Temanizdaki her bir yoruma nasil link verebileceginizi aciklamaktadir. Bu , insanlarin ,yorumlarin duzenli olarak alinti yapildigi belirli blog cesitleri yapmak icin [...]

  3. [...] text box, and displaying a link to the comments RSS feed. The tutorial did not discuss how to give each comment its own link, a tip that I find particularly handy for referring to specific [...]

  4. [...] Giving each comment its own link in WordPress – This shows you how to make each comment into its own kind of mini-post, which is useful if you ever want to link to specific comments [...]

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.