Do you want to add a new column for media ID within the media library of your WordPress website? While there’s probably a plugin for this, we have created a quick code snippet that you can use to add new column with media ID to media library in WordPress.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
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 );
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 11 best WordPress slider plugins and how to add a portfolio to your WordPress website.
Is this code tweakable to indicate in a column row if an image is being used somewhere as a featured image?
nice!!! thanks a lot!
Nice! Thank you!
No problem glad I could help!
great piece of code.
any way you can make the list sortable by this column?