[wp-hackers] Separating Pings from Comments in WordPress 2.7

Matthew Martz matt at sivel.net
Mon Oct 6 17:58:59 GMT 2008


On Mon, Oct 6, 2008 at 12:26 PM, Ryan Boren <ryan at boren.nu> wrote:
> On Mon, Oct 6, 2008 at 6:32 AM, Matthew Martz <matt at sivel.net> wrote:
>> I've been working on writing up a how to on separating pings from comments
>> in WordPress 2.7 for the past few days.  I finally decided to publish it and
>> figured some of you may find it useful.
>>
>> http://sivel.net/2008/10/wp-27-comment-separation/
>
> You can customize your li output by registering a callback.  The
> callback should not output the closing li tag, the walker will do
> that.  With a callback you don't have to do your own loop and you
> don't have to handle threading yourself.  Also, I'm think of adding a
> separate_comments boolean to comments_template() so themes can
> indicate they want comments separated with counts for each type.
>
> wp_list_comments(array('callback' => 'custom_comment'));
>
> function custom_comment($comment, $args, $depth) {
>       $GLOBALS['comment'] = $comment;
> ?>
> <li <?php comment_class(); ?> id="comment-<?php comment_ID( ); ?>">
>        <?php echo get_avatar( $comment->user_id,
> $comment->comment_author_email, 32 ); ?>
>        <h4>
>                <?php comment_author_link( ); ?>
>                <span class="meta"><?php comment_time( ); ?> on <?php
> comment_date( ); ?> | <a href="#comment-<?php comment_ID( ); ?>">#</a>
> | <?php echo comment_reply_link(array('depth' => $depth, 'max_depth'
> => $args['depth'])) ?><?php edit_comment_link( __( 'e' ),
> '&nbsp;|&nbsp;',''); ?></span>
>        </h4>
>        <?php comment_text( ); ?>
>
> <?php
> }
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>

Thanks for the tip Ryan!  I seemed to have overlooked the significance
of the callback argument.  I have updated the how to with this and
removed the foreach loop.

-- 
Matt Martz
matt at sivel.net


More information about the wp-hackers mailing list