Modify wp_list_comments

To modify the wp_list_comments() function from WordPress. I’ve found the following snippet for your functions.php.

<?php
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<div class="post">
<strong><?php printf(__(the_title().' your title %s'), get_comment_author_link()) ?></strong>
<?php if ($comment->comment_approved == '0') : ?>
<span class="error"><?php _e('Your comment is awaiting moderation.') ?></span>
<?php endif; ?>
<div class="comment-meta commentmetadata">
<p><?php comment_text() ?></p>
</div>
</div><!--End post-->
<?php
 }
 ?>

I’ve used this code to modify the title for a review (comment) from “… says” to “the_title() review from … “.

To call this function i’ve used the “callback” function for WordPress comments as follows:

<?php wp_list_comments('callback=mytheme_comment'); ?>

The WordPress Developer documentatiom from the wp_list_comments function:

http://codex.wordpress.org/Function_Reference/wp_list_comments

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s