Home / admin / Add new column with media ID to media library
  • How to Add new column with media ID to media library

    add-new-column-with-media-id-to-media-library

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

    wordpress snippet : PHP

    <>
    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 );
    

    ( WordPress codex functions, hooks, in this snippet. )

    add_filter, __,
  • 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!