Skip to content

How To Add URL Column To WordPress Media Library

Uploading images to WordPress, then getting the direct link to the images wastes a lot of time. We will add a URL column to WordPress media library to solve this problem.

Just add the following snippet to your current theme’s functions.php file:

function muc_column( $cols ) {
        $cols["media_url"] = "URL";
        return $cols;
}
function muc_value( $column_name, $id ) {
        if ( $column_name == "media_url" ) echo '<input type="text" width="100%" onclick="jQuery(this).select();" value="'. wp_get_attachment_url( $id ). '" readonly="true" />';
}
add_filter( 'manage_media_columns', 'muc_column' );
add_action( 'manage_media_custom_column', 'muc_value', 10, 2 );

The original version of this forked snippet comes from Steve Taylor’s website. Kevin of WPSnipp.com replaced the text with an input box, while I added read only property to it.

Leave a Reply

Your email address will not be published. Required fields are marked *