Select Page

The Media Library page in the WordPress admin dashboard doesn’t display the Attachment ID of the images.

If you want to display the attachment ID of the images in the Media Library, then you can add this code to your functions.php file:

// Adds a new column called Attachment ID to the Media Library admin page.
function add_attachment_id_column_media_library($columns){
	$columns['media_attachment_id'] = "Attachment ID"; // Adds Attachment ID to the list of columns.
	return $columns;
add_filter('manage_media_columns', 'add_attachment_id_column_media_library', 1);

// Outputs the attachment ID for each attachment in the Attachment ID column.
function show_attachment_id_media_library($column_id, $id){
	if($column_id === 'media_attachment_id'){
		echo $id; // Output the ID of the attachment.
add_action('manage_media_custom_column', 'show_attachment_id_media_library', 1, 2);

The first function in the above code adds a new column to the list of columns on the Media Library admin page. The second function outputs the attachment ID for every attachment in the attachment column.