Customizing Comments on Posts

I have implemented custom code for generating comments on post page using callback function in functions.php.

function MYTHEME_comment($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?>

<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
   <div class="comment-author vcard">
     <?php echo get_avatar($comment,$size='48' ); ?>
       <div class="comment-meta"><a href="<?php the_author_meta( 'user_url'); ?>"><?php printf(__('%s'), get_comment_author_link()) ?></a></div>
     </div>
     <div class="clear"></div>

     <?php if ($comment->comment_approved == '0') : ?>
       <em><?php _e('Your comment is awaiting moderation.') ?></em>
       <br />
     <?php endif; ?>

     <div class="comment-text"> 
         <?php comment_text() ?>
     </div>

   <div class="reply">
      <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
       <span class="comment-date"> <?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),'  ','') ?></span>
   </div>

Here is a pastebin of the same code http://pastebin.com/nUjvsFua

Read More

It generates basic code to show all the comments on that post.
I want the first five comments to be shown and then a “View more” button to show remaining comments. Any guide on how can I achieve this?

Related posts

Leave a Reply

1 comment