Title: WP_Media_List_Table::column_parent
Published: August 18, 2015
Last modified: May 20, 2026

---

# WP_Media_List_Table::column_parent( WP_Post $post )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#wp--skip-link--target)

Handles the parent column output.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#parameters)󠁿

 `$post`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)required

The current [WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
object.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#source)󠁿

    ```php
    public function column_parent( $post ) {
    	$user_can_edit = current_user_can( 'edit_post', $post->ID );

    	if ( $post->post_parent > 0 ) {
    		$parent = get_post( $post->post_parent );
    	} else {
    		$parent = false;
    	}

    	if ( $parent ) {
    		$title       = _draft_or_post_title( $post->post_parent );
    		$parent_type = get_post_type_object( $parent->post_type );

    		if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) {
    			printf( '<strong><a href="%s">%s</a></strong>', get_edit_post_link( $post->post_parent ), $title );
    		} elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) {
    			printf( '<strong>%s</strong>', $title );
    		} else {
    			_e( '(Private post)' );
    		}

    		if ( $user_can_edit ) :
    			$detach_url = add_query_arg(
    				array(
    					'parent_post_id' => $post->post_parent,
    					'media[]'        => $post->ID,
    					'_wpnonce'       => wp_create_nonce( 'bulk-' . $this->_args['plural'] ),
    				),
    				'upload.php'
    			);
    			printf(
    				'<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>',
    				$detach_url,
    				/* translators: %s: Title of the post the attachment is attached to. */
    				esc_attr( sprintf( __( 'Detach from &#8220;%s&#8221;' ), $title ) ),
    				__( 'Detach' )
    			);
    		endif;
    	} else {
    		_e( '(Unattached)' );
    		?>
    		<?php
    		if ( $user_can_edit ) {
    			$title = _draft_or_post_title( $post->post_parent );
    			printf(
    				'<br /><a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>',
    				$post->ID,
    				/* translators: %s: Attachment title. */
    				esc_attr( sprintf( __( 'Attach &#8220;%s&#8221; to existing content' ), $title ) ),
    				__( 'Attach' )
    			);
    		}
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-media-list-table.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/class-wp-media-list-table.php#L608)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/class-wp-media-list-table.php#L608-L661)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#related)󠁿

| Uses | Description | 
| [_draft_or_post_title()](https://developer.wordpress.org/reference/functions/_draft_or_post_title/)`wp-admin/includes/template.php` |

Gets the post title.

  | 
| [get_edit_post_link()](https://developer.wordpress.org/reference/functions/get_edit_post_link/)`wp-includes/link-template.php` |

Retrieves the edit post link for post.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [_e()](https://developer.wordpress.org/reference/functions/_e/)`wp-includes/l10n.php` |

Displays translated text.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_attr()](https://developer.wordpress.org/reference/functions/esc_attr/)`wp-includes/formatting.php` |

Escaping for HTML attributes.

  | 
| [wp_create_nonce()](https://developer.wordpress.org/reference/functions/wp_create_nonce/)`wp-includes/pluggable.php` |

Creates a cryptographic token tied to a specific action, user, user session, and window of time.

  | 
| [add_query_arg()](https://developer.wordpress.org/reference/functions/add_query_arg/)`wp-includes/functions.php` |

Retrieves a modified URL query string.

  | 
| [get_post()](https://developer.wordpress.org/reference/functions/get_post/)`wp-includes/post.php` |

Retrieves post data given a post ID or post object.

  | 
| [get_post_type_object()](https://developer.wordpress.org/reference/functions/get_post_type_object/)`wp-includes/post.php` |

Retrieves a post type object by name.

  |

[Show 8 more](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.3.0](https://developer.wordpress.org/reference/since/4.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_media_list_table%2Fcolumn_parent%2F)
before being able to contribute a note or feedback.