Title: WP_Comments_List_Table::single_row
Published: April 25, 2014
Last modified: February 24, 2026

---

# WP_Comments_List_Table::single_row( WP_Comment $item )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_comments_list_table/single_row/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_comments_list_table/single_row/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_comments_list_table/single_row/?output_format=md#related)

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

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

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

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

    ```php
    public function single_row( $item ) {
    	global $post, $comment;

    	// Restores the more descriptive, specific name for use within this method.
    	$comment = $item;

    	if ( $comment->comment_post_ID > 0 ) {
    		$post = get_post( $comment->comment_post_ID );
    	}

    	$edit_post_cap = $post ? 'edit_post' : 'edit_posts';

    	if ( ! current_user_can( $edit_post_cap, $comment->comment_post_ID )
    		&& ( post_password_required( $comment->comment_post_ID )
    			|| ! current_user_can( 'read_post', $comment->comment_post_ID ) )
    	) {
    		// The user has no access to the post and thus cannot see the comments.
    		return false;
    	}

    	$the_comment_class = wp_get_comment_status( $comment );

    	if ( ! $the_comment_class ) {
    		$the_comment_class = '';
    	}

    	$the_comment_class = implode( ' ', get_comment_class( $the_comment_class, $comment, $comment->comment_post_ID ) );

    	$this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );

    	echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
    	$this->single_row_columns( $comment );
    	echo "</tr>\n";

    	unset( $GLOBALS['post'], $GLOBALS['comment'] );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-comments-list-table.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/class-wp-comments-list-table.php#L647)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/class-wp-comments-list-table.php#L647-L682)

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

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

Determines whether the post requires password and whether a correct password has been provided.

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

Returns the classes for the comment div as an array.

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

Retrieves the status of a comment by comment ID.

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

Returns whether the current user has the specified capability.

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

Retrieves post data given a post ID or post object.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_comments_list_table/single_row/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_comments_list_table/single_row/?output_format=md#)

## User Contributed Notes

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