0

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...

1
  • Would be better if you show what you did to remove the "Unattached link"...
    – brasofilo
    Commented Feb 11, 2013 at 23:01

1 Answer 1

0

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

1
  • 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
    Commented Feb 12, 2013 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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