Title: WP_Media_List_Table::display_rows
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Media_List_Table::display_rows()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wp_media_list_table/display_rows/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_media_list_table/display_rows/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_media_list_table/display_rows/?output_format=md#changelog)

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

Generates the list table rows.

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

    ```php
    public function display_rows() {
    	global $post, $wp_query;

    	$post_ids = wp_list_pluck( $wp_query->posts, 'ID' );
    	reset( $wp_query->posts );

    	$this->comment_pending_count = get_pending_comments_num( $post_ids );

    	add_filter( 'the_title', 'esc_html' );

    	while ( have_posts() ) :
    		the_post();

    		if ( $this->is_trash && 'trash' !== $post->post_status
    			|| ! $this->is_trash && 'trash' === $post->post_status
    		) {
    			continue;
    		}

    		$post_owner = ( get_current_user_id() === (int) $post->post_author ) ? 'self' : 'other';
    		?>
    		<tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>">
    			<?php $this->single_row_columns( $post ); ?>
    		</tr>
    		<?php
    	endwhile;
    }
    ```

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

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

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

Gets the number of pending comments on a post or posts.

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

Determines whether current WordPress query has posts to loop over.

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

Iterate the post index in the loop.

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

Plucks a certain field out of each object or array in an array.

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

Adds a callback function to a filter hook.

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

Gets the current user’s ID.

  |

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

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

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

## User Contributed Notes

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