Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've already removed the Unattached link through functions.php, the last thing I need now is to remove the (Unattached) Attach from "Uploaded to" in Media Library. I've no clue about what code should I add in functions.php to get rid of it and it's hours I'm searching on the web... Help please...

share|improve this question
    
Would be better if you show what you did to remove the "Unattached link"... –  brasofilo Feb 11 '13 at 23:01
add comment

1 Answer

up vote 0 down vote accepted

It seems there is no other way than de-registering the column and building your own.

The code of the custom column is adapted from class-wp-media-list-table.php.

add_filter( 'manage_upload_columns', 'columns_manage_wpse_85405' );
add_action( 'manage_media_custom_column', 'columns_display_wpse_85405', 10, 2 );

function columns_manage_wpse_85405( $columns ) 
{
    unset( $columns['parent'] );
    $columns['attached'] = 'Parent';
    return $columns;
}

function columns_display_wpse_85405( $column_name, $post_id ) 
{
    if( 'attached' == $column_name )
    {
        $attributes = "class='$column_name column-$column_name'";
        $the_post = get_post( $post_id );

        if ( $the_post->post_parent > 0 ) 
        {
            $title = '';
            if ( get_post( $the_post->post_parent ) ) 
            {
                $title =_draft_or_post_title( $the_post->post_parent );
            }
            ?>
            <strong>
                <?php 
                if( current_user_can( 'edit_post', $the_post->post_parent ) ) 
                { ?>
                    <a href="<?php echo get_edit_post_link( $the_post->post_parent ); ?>">
                        <?php echo $title ?></a><?php
                } 
                else 
                {
                    echo $title;
                } 
                ?>
            </strong>, <?php echo get_the_time( __( 'Y/m/d' ) ); 
            ?>          
        <?php
        } else {
        ?>
            <?php _e( '(Unattached)' ); ?>
        <?php
        }
    }
}

Results in:
New parent Media column

share|improve this answer
    
Man, you rock! It was what i've been looking. Without this hack my contributors could attach their images to pages and posts in my blog, no matter if they wrote them or not. –  user27309 Feb 12 '13 at 10:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.