Title: wp_list_comments()
Last modified: August 19, 2016

---

# wp_list_comments()

 *  [verticalimit](https://wordpress.org/support/users/verticalimit/)
 * (@verticalimit)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wp_list_comments-3/)
 * Hello,
 * I am currently working on a local server.
 * I need to create a callback function as described [here](http://codex.wordpress.org/Function_Reference/wp_list_comments#Comments_Only_With_A_Custom_Comment_Display)
   to format the comments.
 * It is quite simple to do as you only have to cut and paste the code in each file(
   functions.php + comments.php) and to give the same name to the callback function.
 * But i can’t have it running.
    Once i modified the files, i get a blank page. 
   I need to upload again my theme to have it running.
 * Thanks for your help,

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wp_list_comments-3/#post-1625471)
 * Sounds like you have an error in your callback function.
 *  Thread Starter [verticalimit](https://wordpress.org/support/users/verticalimit/)
 * (@verticalimit)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wp_list_comments-3/#post-1625495)
 * How can it be if i only copy and paste the codex code?
 *  Thread Starter [verticalimit](https://wordpress.org/support/users/verticalimit/)
 * (@verticalimit)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wp_list_comments-3/#post-1625512)
 * Ok I found my mistake.
    Just forgot to put <?php
 * Next one:
    My theme is coded with: `wp_list_comments('avatar_size='.$avsize);`
 * I want to keep it as i would prefer to remain with the original avatar settings
   instead of doing it with the callback function.
 * I need to add this line to call the callback function:
    `<?php wp_list_comments('
   callback=mytheme_comment'); ?>`
 * How can i add those two lines together please? only one <?php wp_list_comments()
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wp_list_comments-3/#post-1625530)
 * Try `<?php wp_list_comments('avatar_size='.$avsize . '&callback=mytheme_comment');?
   >`
 *  Thread Starter [verticalimit](https://wordpress.org/support/users/verticalimit/)
 * (@verticalimit)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wp_list_comments-3/#post-1625730)
 * Thanks Esmi. It worked fine.
    But still there is sthg wrong. The header and the
   footer changed of colors for example.
 * I don’t think it is connected to your code but rather because i added mytheme_comment
   function in the theme.
 * Here are the changes i have made so far:
 * **1. functions.php**
 * I added this code at the end of the file:
 *     ```
       <?php
       function im_comment($comment, $args, $depth) {
          $GLOBALS['comment'] = $comment; ?>
          <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
       	 <div id="comment-<?php comment_ID(); ?>">
       	  <div class="comment-author vcard">
       		 <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
       		 <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
       	  </div>
       	  <?php if ($comment->comment_approved == '0') : ?>
       		 <em><?php _e('Your comment is awaiting moderation.') ?></em>
       		 <br />
       	  <?php endif; ?>
       	  <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'  ','') ?></div>
       	  <?php comment_text() ?>
       	  <div class="reply">
       		 <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
       	  </div>
       	 </div>
       <?php
       		}
       ?>
       ```
   
 * 2.comments.php
 * I replaced the following line:
    `wp_list_comments('avatar_size='.$avsize);`
 * with:
    `wp_list_comments('avatar_size='.$avsize.'&callback=im_comment');`
 * How can i avoid to loose the original configuration of my theme that i have made
   through the admin panel?
 * Thanks,
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wp_list_comments-3/#post-1625746)
 * I don’t see how a comment callback function would affect you header and footer
   styling unless you inadvertently:
 * – removed something from functions.php when you added your callback
 * – or introduced a validation error into your pages.
 * Have you tried validating your pages and correcting any markup errors?
 *  Thread Starter [verticalimit](https://wordpress.org/support/users/verticalimit/)
 * (@verticalimit)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wp_list_comments-3/#post-1625792)
 * Thanks for your help.
    How can you validate pages when your work on a local server
   pls?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wp_list_comments-3/#post-1625803)
 * If you use Firefox, the Web Developer Toolbar add-on allows you to submit local
   pages to the online validator. There’s also an HTML Validator add-on that parses
   pages on the fly – even local ones.
 * Other than that, you could copy your page’s output and use the [direct input option](http://validator.w3.org/#validate_by_input)
   in the W3C Validator.
 *  Thread Starter [verticalimit](https://wordpress.org/support/users/verticalimit/)
 * (@verticalimit)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/wp_list_comments-3/#post-1625943)
 * I found out that if i was including the callback function within <?php … ?> like
   this :
 *     ```
       <?php
       ....
       function mytheme_comment($comment, $args, $depth) {
          $GLOBALS['comment'] = $comment; ?>
          <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
            <div id="comment-<?php comment_ID(); ?>">
             <div class="comment-author vcard">
                <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
   
                <?php printf(__('<cite class="fn">%s</cite> <span class="says">dit:</span>'), get_comment_author_link()) ?>
             </div>
             <?php if ($comment->comment_approved == '0') : ?>
                <em><?php _e('Your comment is awaiting moderation.') ?></em>
                <br />
             <?php endif; ?>
   
             <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'  ','') ?></div>
   
             <?php comment_text() ?>
   
             <div class="reply">
                <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
             </div>
            </div>
       <?php
               }
       ?>
       ```
   
 * it was working better than adding at the end the following code:
 *     ```
       <?php
       function im_comment($comment, $args, $depth) {
          $GLOBALS['comment'] = $comment; ?>
          <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
            <div id="comment-<?php comment_ID(); ?>">
             <div class="comment-author vcard">
                <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
                <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
             </div>
             <?php if ($comment->comment_approved == '0') : ?>
                <em><?php _e('Your comment is awaiting moderation.') ?></em>
                <br />
             <?php endif; ?>
             <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'  ','') ?></div>
             <?php comment_text() ?>
             <div class="reply">
                <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
             </div>
            </div>
       <?php
               }
       ?>
       ```
   
 * To call the function, i used:
    `wp_list_comments('avatar_size='.$avsize.'&callback
   =im_comment');`
 * and after:
    `wp_list_comments('avatar_size='.$avsize.'type=comment&callback=im_comment');`
 * As a result, the theme and its parameters are remaining but the comments are 
   not showing.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘wp_list_comments()’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 2 participants
 * Last reply from: [verticalimit](https://wordpress.org/support/users/verticalimit/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/wp_list_comments-3/#post-1625943)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
