Modify wp_list_comments

To modify the wp_list_comments() function from WordPress. I’ve found the following snippet for your functions.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><!--End post-->

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:


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s