Share this...

A while ago, I asked on the support forum for Graphene if it would be possible to include the permalink for each comment. That will be an option with the next version (1.7) of the theme (thanks, Syahir!), but it’s possible to do that even before then. In fact, thanks to the wide number of comment functions WordPress has available, you can add a number of informative, if not entirely useful, bits of information to your comments.

To get started, you’re going to need to know how to use Graphene’s action hook widget areas. If you haven’t done so already, go ahead and read my tutorial.

Next, install the PHP widget. You’re going to need that.

Now, go to Graphene Options >> Advanced Options >> Action Hook Widget Areas. Click on “includes/theme-comments.php” and then tick the box marked ““. Click the “Save Options” button at the bottom, and then navigate to your Widgets pane. You will now see a widget area titled “Graphene Comment Meta”. Drag a PHP widget to that widget area.

This is where the fun begins.

The WordPress function for the comment’s permalink is `comment_ID()`. You can simply enter that in the PHP widget and call it a day. Or, you can add a bit of HTML and a few other functions to spice up your comments. Here’s what’s in my comment meta:

<span style="color: #6B6B6B; font-size:11px;">
Posted from <a href="http://<?php comment_author_IP(); ?>" target="blank">
<?php comment_author_IP(); ?>
</a>
&nbsp;|&nbsp;
<a href="#comment-<?php comment_ID() ?>">Permalink</a>
&nbsp;|&nbsp;
<?php post_comments_feed_link( $link_text = 'Comment feed for this post.' ) ?>
</span>

You’ll notice that I wrapped the entire thing in a `<span>` so that I could style it. I also added the comment author’s IP address, as well as the RSS feed for the comments on that post (for the day when I have enough comments to make it worthwhile to pay attention to such things).

If you want other ideas about how to use these various WordPress functions, then read this page on the WordPress Codex which explains the `comment_ID()` function. At the bottom, under “Related” you will find a number of other comment meta functions you can have fun with.


Share this...
Except for material released under a Creative Commons License: ©2021 Kenneth John Odle All Rights ReservedPermalink for this article:
https://techblog.kjodle.net/2012/03/23/add-comment-metadata-to-the-graphene-theme-for-wordpress/