[wp-testers] Styling of comments in WP2.7

Austin Matzko if.website at gmail.com
Wed Oct 29 11:50:52 GMT 2008


On Wed, Oct 29, 2008 at 7:16 AM, Jonathan Gabor <jgabor at gmail.com> wrote:
> But since wp_list_comments() outputs all of the HTML, I can't really change
> the style/design of it - except modifiying font/size/width/height. What if I
> want to change position of it?
>
> For example, what if I want the comment-meta div to appear after the
> comment-text? I really don't want to start using absolute positioning for
> this...

You can pass an array of options to wp_list_comments(), including the
"callback" option:
wp_list_comments(array('callback' => 'my_custom_comment_markup_function'));

If it's defined, the callback acts as a replacement for
wp_list_comments()'s default output.  Its first argument is $comment,
so for my example above you could do the following:

function my_custom_comment_markup_function($comment) {
$GLOBALS['comment'] = $comment;
[ put here all the template tags for comments that you're used to,
such as get_comment_author() and get_avatar() ]
}

Just define this in your theme's functions.php file, for example, and
you're all set.


More information about the wp-testers mailing list