wordpress snippets last updated   : July 14, 2014
we now have 634 snippets

Add new column with media ID to media library

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will add a new column within the media library with the attachment ID.

snippet :  PHPcopy
function column_id($columns) {
    $columns['colID'] = __('ID');
    return $columns;
}
add_filter( 'manage_media_columns', 'column_id' );
function column_id_row($columnName, $columnID){
    if($columnName == 'colID'){
       echo $columnID;
    }
}
add_filter( 'manage_media_custom_column', 'column_id_row', 10, 2 );

  • Constantin

    great piece of code.
    any way you can make the list sortable by this column?

  • JustSomeBlogger

    Nice! Thank you!

    • http://wpsnipp.com Kevin Chard

      No problem glad I could help!

jqsnipp.com | we just launched jquery snippets website