Title: Walker_Comment::comment
Published: April 25, 2014
Last modified: April 28, 2025

---

# Walker_Comment::comment( WP_Comment $comment, int $depth, array $args )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#wp--skip-link--target)

Outputs a single comment.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#see-also)󠁿

 * [wp_list_comments()](https://developer.wordpress.org/reference/functions/wp_list_comments/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#parameters)󠁿

 `$comment`[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
required

Comment to display.

`$depth`intrequired

Depth of the current comment.

`$args`arrayrequired

An array of arguments.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#source)󠁿

    ```php
    protected function comment( $comment, $depth, $args ) {
    	if ( 'div' === $args['style'] ) {
    		$tag       = 'div';
    		$add_below = 'comment';
    	} else {
    		$tag       = 'li';
    		$add_below = 'div-comment';
    	}

    	$commenter          = wp_get_current_commenter();
    	$show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author'];

    	if ( $commenter['comment_author_email'] ) {
    		$moderation_note = __( 'Your comment is awaiting moderation.' );
    	} else {
    		$moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.' );
    	}
    	?>
    	<<?php echo $tag; ?> <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?> id="comment-<?php comment_ID(); ?>">
    	<?php if ( 'div' !== $args['style'] ) : ?>
    	<div id="div-comment-<?php comment_ID(); ?>" class="comment-body">
    	<?php endif; ?>
    	<div class="comment-author vcard">
    		<?php
    		if ( 0 !== $args['avatar_size'] ) {
    			echo get_avatar( $comment, $args['avatar_size'] );
    		}
    		?>
    		<?php
    		$comment_author = get_comment_author_link( $comment );

    		if ( '0' === $comment->comment_approved && ! $show_pending_links ) {
    			$comment_author = get_comment_author( $comment );
    		}

    		printf(
    			/* translators: %s: Comment author link. */
    			__( '%s <span class="says">says:</span>' ),
    			sprintf( '<cite class="fn">%s</cite>', $comment_author )
    		);
    		?>
    	</div>
    	<?php if ( '0' === $comment->comment_approved ) : ?>
    	<em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em>
    	<br />
    	<?php endif; ?>

    	<div class="comment-meta commentmetadata">
    		<?php
    		printf(
    			'<a href="%s">%s</a>',
    			esc_url( get_comment_link( $comment, $args ) ),
    			sprintf(
    				/* translators: 1: Comment date, 2: Comment time. */
    				__( '%1$s at %2$s' ),
    				get_comment_date( '', $comment ),
    				get_comment_time()
    			)
    		);

    		edit_comment_link( __( '(Edit)' ), ' &nbsp;&nbsp;', '' );
    		?>
    	</div>

    	<?php
    	comment_text(
    		$comment,
    		array_merge(
    			$args,
    			array(
    				'add_below' => $add_below,
    				'depth'     => $depth,
    				'max_depth' => $args['max_depth'],
    			)
    		)
    	);
    	?>

    	<?php
    	comment_reply_link(
    		array_merge(
    			$args,
    			array(
    				'add_below' => $add_below,
    				'depth'     => $depth,
    				'max_depth' => $args['max_depth'],
    				'before'    => '<div class="reply">',
    				'after'     => '</div>',
    			)
    		)
    	);
    	?>

    	<?php if ( 'div' !== $args['style'] ) : ?>
    	</div>
    	<?php endif; ?>
    	<?php
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-walker-comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-walker-comment.php#L299)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-walker-comment.php#L299-L396)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#related)󠁿

| Uses | Description | 
| [get_avatar()](https://developer.wordpress.org/reference/functions/get_avatar/)`wp-includes/pluggable.php` |

Retrieves the avatar `<img>` tag for a user, email address, MD5 hash, comment, or post.

  | 
| [edit_comment_link()](https://developer.wordpress.org/reference/functions/edit_comment_link/)`wp-includes/link-template.php` |

Displays the edit comment link with formatting.

  | 
| [comment_reply_link()](https://developer.wordpress.org/reference/functions/comment_reply_link/)`wp-includes/comment-template.php` |

Displays the HTML content for reply to comment link.

  | 
| [comment_ID()](https://developer.wordpress.org/reference/functions/comment_id/)`wp-includes/comment-template.php` |

Displays the comment ID of the current comment.

  | 
| [get_comment_link()](https://developer.wordpress.org/reference/functions/get_comment_link/)`wp-includes/comment-template.php` |

Retrieves the link to a given comment.

  | 
| [get_comment_time()](https://developer.wordpress.org/reference/functions/get_comment_time/)`wp-includes/comment-template.php` |

Retrieves the comment time of the current comment.

  | 
| [comment_text()](https://developer.wordpress.org/reference/functions/comment_text/)`wp-includes/comment-template.php` |

Displays the text of the current comment.

  | 
| [comment_class()](https://developer.wordpress.org/reference/functions/comment_class/)`wp-includes/comment-template.php` |

Generates semantic classes for each comment element.

  | 
| [get_comment_date()](https://developer.wordpress.org/reference/functions/get_comment_date/)`wp-includes/comment-template.php` |

Retrieves the comment date of the current comment.

  | 
| [get_comment_author_link()](https://developer.wordpress.org/reference/functions/get_comment_author_link/)`wp-includes/comment-template.php` |

Retrieves the HTML link to the URL of the author of the current comment.

  | 
| [get_comment_author()](https://developer.wordpress.org/reference/functions/get_comment_author/)`wp-includes/comment-template.php` |

Retrieves the author of the current comment.

  | 
| [wp_get_current_commenter()](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/)`wp-includes/comment.php` |

Gets current commenter’s name, email, and URL.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  |

[Show 9 more](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#)

| Used by | Description | 
| [Walker_Comment::start_el()](https://developer.wordpress.org/reference/classes/walker_comment/start_el/)`wp-includes/class-walker-comment.php` |

Starts the element output.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.6.0](https://developer.wordpress.org/reference/since/3.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwalker_comment%2Fcomment%2F)
before being able to contribute a note or feedback.